diff options
author | 2023-01-04 23:29:18 -0500 | |
---|---|---|
committer | 2023-01-04 23:29:18 -0500 | |
commit | 94b1e168b2b97b48b81f7a8f64406b0a6f64184e (patch) | |
tree | f57362a0fa01bfe8f0ad75a447c4c9e10bc15756 /3rdparty/bgfx/examples/21-deferred/deferred.cpp | |
parent | 5581eaa50a42256242f32569f59ce10d70ddd8c2 (diff) |
Revert "Update BGFX, BX and BIMG (#10750)" (#10787)
This reverts commit 5581eaa50a42256242f32569f59ce10d70ddd8c2 due to link failure on macOS.
Diffstat (limited to '3rdparty/bgfx/examples/21-deferred/deferred.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/21-deferred/deferred.cpp | 68 |
1 files changed, 12 insertions, 56 deletions
diff --git a/3rdparty/bgfx/examples/21-deferred/deferred.cpp b/3rdparty/bgfx/examples/21-deferred/deferred.cpp index 6c379fd3fe1..375edbab9fc 100644 --- a/3rdparty/bgfx/examples/21-deferred/deferred.cpp +++ b/3rdparty/bgfx/examples/21-deferred/deferred.cpp @@ -1,13 +1,13 @@ /* - * Copyright 2011-2022 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE + * Copyright 2011-2021 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ -#include <bx/bounds.h> #include "common.h" #include "bgfx_utils.h" #include "imgui/imgui.h" #include "camera.h" +#include "bounds.h" namespace { @@ -211,8 +211,6 @@ public: bgfx::Init init; init.type = args.m_type; init.vendorId = args.m_pciId; - init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); - init.platformData.ndt = entry::getNativeDisplayHandle(); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; @@ -277,7 +275,6 @@ public: u_mtx = bgfx::createUniform("u_mtx", bgfx::UniformType::Mat4); u_lightPosRadius = bgfx::createUniform("u_lightPosRadius", bgfx::UniformType::Vec4); u_lightRgbInnerR = bgfx::createUniform("u_lightRgbInnerR", bgfx::UniformType::Vec4); - u_layer = bgfx::createUniform("u_layer", bgfx::UniformType::Vec4); // Create program from shaders. m_geomProgram = loadProgram("vs_deferred_geom", "fs_deferred_geom"); @@ -291,15 +288,11 @@ public: if (0 != (BGFX_CAPS_TEXTURE_2D_ARRAY & bgfx::getCaps()->supported) ) { - m_lightTaProgram = loadProgram("vs_deferred_light", "fs_deferred_light_ta"); - m_combineTaProgram = loadProgram("vs_deferred_combine", "fs_deferred_combine_ta"); - m_debugTaProgram = loadProgram("vs_deferred_debug", "fs_deferred_debug_ta"); + m_lightTaProgram = loadProgram("vs_deferred_light", "fs_deferred_light_ta"); } else { - m_lightTaProgram = BGFX_INVALID_HANDLE; - m_combineTaProgram = BGFX_INVALID_HANDLE; - m_debugTaProgram = BGFX_INVALID_HANDLE; + m_lightTaProgram = BGFX_INVALID_HANDLE; } if (0 != (BGFX_CAPS_IMAGE_RW & bgfx::getCaps()->supported) @@ -395,19 +388,7 @@ public: } bgfx::destroy(m_combineProgram); - - if (bgfx::isValid(m_combineTaProgram) ) - { - bgfx::destroy(m_combineTaProgram); - } - bgfx::destroy(m_debugProgram); - - if (bgfx::isValid(m_debugTaProgram) ) - { - bgfx::destroy(m_debugTaProgram); - } - bgfx::destroy(m_lineProgram); bgfx::destroy(m_textureColor); @@ -420,7 +401,6 @@ public: bgfx::destroy(s_depth); bgfx::destroy(s_light); - bgfx::destroy(u_layer); bgfx::destroy(u_lightPosRadius); bgfx::destroy(u_lightRgbInnerR); bgfx::destroy(u_mtx); @@ -699,7 +679,7 @@ public: // Draw lights into light buffer. for (int32_t light = 0; light < m_numLights; ++light) { - bx::Sphere lightPosRadius; + Sphere lightPosRadius; float lightTime = time * m_lightAnimationSpeed * (bx::sin(light/float(m_numLights) * bx::kPiHalf ) * 0.5f + 0.5f); lightPosRadius.center.x = bx::sin( ( (lightTime + light*0.47f) + bx::kPiHalf*1.37f ) )*offset; @@ -707,7 +687,7 @@ public: lightPosRadius.center.z = bx::sin( ( (lightTime + light*0.37f) + bx::kPiHalf*1.57f ) )*2.0f; lightPosRadius.radius = 2.0f; - bx::Aabb aabb; + Aabb aabb; toAabb(aabb, lightPosRadius); const bx::Vec3 box[8] = @@ -839,30 +819,21 @@ public: } // Combine color and light buffers. - bgfx::setTexture(0, s_albedo, bgfx::getTexture(m_gbuffer, 0) ); + bgfx::setTexture(0, s_albedo, m_gbufferTex[0]); bgfx::setTexture(1, s_light, m_lightBufferTex); bgfx::setState(0 | BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A ); screenSpaceQuad( (float)m_width, (float)m_height, s_texelHalf, m_caps->originBottomLeft); - - if (bgfx::isValid(m_lightTaProgram) - && m_useTArray) - { - bgfx::submit(kRenderPassCombine, m_combineTaProgram); - } - else - { - bgfx::submit(kRenderPassCombine, m_combineProgram); - } + bgfx::submit(kRenderPassCombine, m_combineProgram); if (m_showGBuffer) { const float aspectRatio = float(m_width)/float(m_height); // Draw m_debug m_gbuffer. - for (uint8_t ii = 0; ii < BX_COUNTOF(m_gbufferTex); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_gbufferTex); ++ii) { float mtx[16]; bx::mtxSRT(mtx @@ -874,21 +845,9 @@ public: bgfx::setTransform(mtx); bgfx::setVertexBuffer(0, m_vbh); bgfx::setIndexBuffer(m_ibh, 0, 6); - bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_gbuffer, ii) ); + bgfx::setTexture(0, s_texColor, m_gbufferTex[ii]); bgfx::setState(BGFX_STATE_WRITE_RGB); - - if (ii != BX_COUNTOF(m_gbufferTex) - 1 - && bgfx::isValid(m_lightTaProgram) - && m_useTArray) - { - const float layer[4] = { float(ii) }; - bgfx::setUniform(u_layer, layer); - bgfx::submit(kRenderPassDebugGBuffer, m_debugTaProgram); - } - else - { - bgfx::submit(kRenderPassDebugGBuffer, m_debugProgram); - } + bgfx::submit(kRenderPassDebugGBuffer, m_debugProgram); } } } @@ -918,7 +877,6 @@ public: bgfx::UniformHandle u_mtx; bgfx::UniformHandle u_lightPosRadius; bgfx::UniformHandle u_lightRgbInnerR; - bgfx::UniformHandle u_layer; bgfx::ProgramHandle m_geomProgram; bgfx::ProgramHandle m_lightProgram; @@ -926,9 +884,7 @@ public: bgfx::ProgramHandle m_lightUavProgram; bgfx::ProgramHandle m_clearUavProgram; bgfx::ProgramHandle m_combineProgram; - bgfx::ProgramHandle m_combineTaProgram; bgfx::ProgramHandle m_debugProgram; - bgfx::ProgramHandle m_debugTaProgram; bgfx::ProgramHandle m_lineProgram; bgfx::TextureHandle m_textureColor; bgfx::TextureHandle m_textureNormal; |