Commit Graph

3216 Commits

Author SHA1 Message Date
Бранимир Караџић
22d5747719 Cleanup. 2021-09-30 17:24:16 -07:00
pezcode
be2c110781
Vulkan: raise maximum number of swapchain images (#2619) 2021-09-30 15:01:39 -07:00
Cedric Guillemet
f9436baea3
store action was not set when clearWithRenderPass false and MSAA on (#2613)
Co-authored-by: Cedric Guillemet <ceguille@microsoft.com>
2021-09-30 11:26:18 -07:00
Gaetan de Villele
89b6c25c4a
fix usage of fatal() function when Clang analyzer is used (#2617) 2021-09-27 19:07:32 -07:00
Christophe Dehais
ad8e7eb974
Simplify vulkan texture resolve (#2611) 2021-09-22 09:20:48 -07:00
Gary Hsu
79d1b4db56
Fix bug when sampler min/mag is anisotropic but mip is point (#2609) 2021-09-21 18:13:49 -07:00
Бранимир Караџић
227ea05dee Fixed transient vertex buffer when vertex layout allocation fails. 2021-09-16 18:32:58 -07:00
Andrew Willmott
1a001a67db
Fix RG16F typo (#2603) 2021-09-16 07:23:27 -07:00
Бранимир Караџић
9ecd462538 Cleanup. 2021-09-09 09:50:17 -07:00
James Fulop
bbc2b76948
Dxgi tearing support (#2601)
* present tearing support

* use existing syncInterval variable
2021-09-09 07:20:01 -07:00
Julian Sikorski
9ab8494bdd
Fix crash when switching to fullscreen with vulkan (#2598)
Without this change, running examples under XWayland, SDL and vulkan
renderer results in a crash. Credit goes to @pezcode:
https://github.com/bkaradzic/bgfx/issues/2593#issuecomment-905462527
2021-08-30 08:33:37 -07:00
Бранимир Караџић
ee0fbea726 Added AGC renderer stub. 2021-08-24 19:35:09 -07:00
pezcode
f80d31f1f4
HLSL: add textureGather for all components (#2595) 2021-08-24 17:26:03 -07:00
pezcode
103179f74d
Vulkan: fix present elapsed calculation (#2592) 2021-08-20 07:15:27 -07:00
pezcode
d77f8686f9
Vulkan: fix layer calculation for (cubemap) array texture update (#2591) 2021-08-20 07:15:10 -07:00
Бранимир Караџић
925fbe30ae Cleanup. 2021-08-14 12:39:50 -07:00
Бранимир Караџић
962a446055 Cleanup. 2021-08-14 08:33:25 -07:00
James Fulop
82ed74ddb6
cleanup (#2579)
* cleanup

remove unused macro parameters

* de-macro CASE_IMPLEMENT_UNIFORM in d3d11, d3d12, mtl, vk

* fix whitespace

* remove undef of macro that was deleted

* collapse switch statements
2021-08-14 06:57:30 -07:00
pezcode
e8281f8656
Vulkan: correctly resolve attachments of destroyed framebuffer (#2576) 2021-08-09 13:42:54 -07:00
pezcode
ae111f1946
Vulkan: fix RGBA8 backbuffer capture (#2575) 2021-08-09 13:42:00 -07:00
jwdevel
59a73fe9d3
Improve detection of EXT_gpu_shader4 (#2572)
This extension is used to detect support for gl_InstanceID and gl_VertexID. However, in more recent
versions of OpenGL, this is built-in functionality. On my system, it does not list that extension,
even though it supports those features, but BGFX was not detecting that.

Updated detection to look for GL>=3.1.

Note 1: even with this change, you do need to compile BGFX with the appropriate
BGFX_CONFIG_RENDERER_OPENGL value (>=31). The default of 21 is not high enough.

Note 2: Even with all of the above, you will likely hit issues with duplicate '#version' lines in
the generated shader code. For that, see issue #xxxx.

fixes issue #2570
2021-08-07 18:02:08 -07:00
Matt Tytel
25ef0e5c85
Weird fix for frame rate doubling after second created window. (#2564)
* Weird fix for frame rate doubling after second created window.

* Don't double buffer with vsync in metal to prevent 2x fps instead.

* Setting number of back buffers in metal if available.

* Better function call syntax.

* Matching maxFrameLatency to maximumDrawableCount in Metal backend.
2021-07-30 08:39:11 -07:00
Nathan Reed
2f1e14ea82
Use already injected RenderDoc dll, or load it from default location (#2561)
* Use already injected RenderDoc dll, or load it from default location

- on Windows, if the process was launched from RenderDoc and the dll is already injected, use it
- otherwise try to load the dll from the default installation path in Program Files
- doesn't need the dll to be copied next to the exe or in the system PATH, which is not the supported way to do it according to BaldurK - see https://github.com/baldurk/renderdoc/issues/2279#issuecomment-844588691

* Restore previous implementation of findModule

* Address PR feedback

Co-authored-by: Nathan Reed <nareed@adobe.com>
2021-07-19 17:33:02 -07:00
James Fulop
9694171d1b
cleanup (#2545)
spelling: treshold -> threshold
2021-06-23 07:14:11 -07:00
James Fulop
684234c089
cleanup (#2544)
replace `long long` with `int64_t`
2021-06-23 07:13:37 -07:00
Бранимир Караџић
40f1d6b0e4 Merge branch 'master' of github.com:bkaradzic/bgfx 2021-06-16 15:19:34 -07:00
Бранимир Караџић
c2974e96d4 Android default is GLES 3.0. 2021-06-16 15:19:22 -07:00
kingscallop
17c9300afd
Allow shaders to be compiled on msys2 (#2539)
Adds support on tools.mk for the msys2 environment. The OS is still
considered windows but the command line tools for mkdir and rmdir
behave as if on linux.

The variable SHADER_TMP on the makefiles also had to be quoted to make
it work on msys2.
2021-06-12 11:36:54 -07:00
kingscallop
c0adb2a51e
Make the generated embedded shader headers the same between linux and gnuwin32 (#2538)
This echo command on the makefile behaves differently between linux and gnuwin32:
```
-@echo extern const uint8_t* $(basename $(<))_pssl;>> $(@)
```

On linux the semicolon immediately ends the echo command and its output is never piped to the embedded shader's header.
If you try to fix it by quoting the string:
```
-@echo "extern const uint8_t* $(basename $(<))_pssl;" >> $(@)
```

It will work on linux but not on gnuwin32 because the quotes will appear on the outputted string.
The solution was to use printf which works consistently between the two.

Also on gnuwin32 the outputted string has 'CRLF' line endings, which clashes with the rest of the 'LF' line endings
of the embedded shaders header which were produced by shaderc.
The solution was to remove the 'CR' from the outputted string by using the tr command.
2021-06-12 10:22:19 -07:00
Бранимир Караџић
e0d26507dc Added BGFX_CONFIG_ENCODER_API_ONLY configuration setting to enable/disable non-encoder API. 2021-06-11 08:05:58 -07:00
Branimir Karadžić
f569fe32a6 Rebuilt all embedded shaders. 2021-06-06 14:51:46 -07:00
Branimir Karadžić
24f047b078 Fixed VS warnings. 2021-06-06 14:51:39 -07:00
kingscallop
73784ac9eb
Split embedded shaders into essl and glsl - Part 1 (#2535)
In non-embedded shaders there is a separation between essl binaries (examples/runtime/shaders/essl)
and glsl binaries (examples/runtime/shaders/glsl). On embedded shaders there is no such separation
and by default essl shaders are being used by the OpenGL runtime. This usually doesn't cause any
issues but in the case of the debugdraw shaders, that started using uvec4, this now leads to a
runtime error. This patch fixes this by splitting the embedded shaders into essl and glsl.

As asked, this is the first part of the change.

To be able to compile the 'examples/common/debugdraw' shaders, pull
request #2362 is needed.
2021-06-06 13:53:26 -07:00
kingscallop
6a529fca4b
Fix usage of bx::findIdentifierMatch for gl_FragDepth (#2533)
When trying to find all the instances of gl_FragDepth
and replace them with bgfx_FragDepth it only finds
the first instance.
2021-06-05 13:56:00 -07:00
simon chen
0b179e59e2
fixed GLES3 bug, when "EGL_KHR_create_context" doesn't exist. (#2529)
* fixed gles3 bug

* fixed sdl bug on android platform
2021-06-05 07:54:14 -07:00
Бранимир Караџић
5db742a7b0 Fixed GLES3 build. 2021-06-03 21:28:10 -07:00
Mirko-Salm
c5dcd4ea9b
fixed missing brackets in ddy, ddy_coarse, and ddy_fine (#2525) 2021-05-31 08:59:41 -07:00
Бранимир Караџић
6baa370801 Fixed transient index buffer functions to all have 32-bit indices support, and removed 16-bit only restriction from docs. 2021-05-25 12:47:28 -07:00
Бранимир Караџић
5ecddbf4d5 Updated version number. 2021-05-19 09:53:54 -07:00
Branimir Karadžić
c5aea5325d Fixed MSVC build. 2021-05-19 07:03:02 -07:00
Бранимир Караџић
a47a1c8917 Fixed WebGL instancing and EGL context upgrade. 2021-05-18 22:41:51 -07:00
Бранимир Караџић
3214539bad Fixing WebGL + Android instancing. 2021-05-18 20:22:46 -07:00
Бранимир Караџић
5c1d99cb8c Fixed build. 2021-05-13 20:31:20 -07:00
Бранимир Караџић
9d8e73f1c1 Fixed warnings. 2021-05-13 12:48:27 -07:00
Бранимир Караџић
41ab81fd51 Cleanup. 2021-05-06 10:59:28 -07:00
Sebastian Marketsmueller
582dfc1e4c
Fix texture validation logic (#2509)
* fix mip level computation for asmjs and add support for srgb textures in es2/webgl

* fix BX_TRACE in glcontext_html5.cpp

* fix wrong logic in texture validation

Co-authored-by: Sebastian Marketsmueller <sebastianm@hq.unity3d.com>
Co-authored-by: Vladimir Vukicevic <vladimir@pobox.com>
2021-05-06 10:58:37 -07:00
pezcode
97c4abef01
GLES: fix compilation (#2508) 2021-05-05 14:24:35 -07:00
pezcode
2c21f68998
VPRT support for D3D11, D3D12, GL (#2507)
* glsl-optimizer: whitelist ARB_shader_viewport_layer_array_enable

* D3D11: remove duplicate structs and enums

* D3D11: report BGFX_CAPS_VIEWPORT_LAYER_ARRAY

* D3D12: report BGFX_CAPS_VIEWPORT_LAYER_ARRAY

* GL: support for BGFX_CAPS_VIEWPORT_LAYER_ARRAY

* D3D11: multi-layer MSAA resolve

* D3D12: multi-layer MSAA resolve

* D3D12: fix binding multi-layer resolved textures

* GL: fix multi-layer rendertarget creation
2021-05-05 11:58:21 -07:00
pezcode
56fbe55b3d
Vulkan: occlusion queries, housekeeping - attempt 2 (#2506)
* Cleanup

* Request host-cached memory for readback

* Request device-visible memory for the uniform buffer

* Use more fine-grained image memory barrier stages

* Don't rebind vertex and index buffers if not necessary

* Timer queries

* Don't transition images during a renderpass

* Cache descriptor sets

* Trigger RenderDoc capture if requested

* Fix invalid command buffer after surface recreation

* Perform clear and blit before compute

* Use init.debug to enable validation layers

...instead of always enabling them in debug config

* Only resolve framebuffer once

* Report number of primitives without index buffer

* Minimize state changes

* Occlusion queries

* Transition swapchain image from undefined layout

* Make sure we have a combined graphics and compute queue family

Existing code already makes that assumption, otherwise we'd need different command queues and explicit resource queue transitions. The spec also guarantees that a device with such a queue family should exist.

* Release cached image views on texture destruction

* Fix stencil-only clear

* Fix non-zero integer format clear

* Annotate all optional functions with their extensions

* Support for BGFX_SAMPLER_SAMPLE_STENCIL

* Remove unused extension functions

* Support for BGFX_SAMPLER_BORDER_COLOR

* Undo descriptor set cache

Try this again in another PR... the hashing doesn't quite work with some bind combinations, and the cache needs a better eviction strategy

* Don't start renderpass for empty draw calls

* Advertize graphics debugger, if present

ie. RenderDoc

* Cleanup

* Only enable required features and extensions

* Don't spam warning about swapchain format fallback

* Cleanup
2021-05-03 10:17:43 -07:00
Бранимир Караџић
9528c5d68a Revert "Vulkan: occlusion queries, housekeeping (#2505)"
This reverts commit 2fb67a707b.
2021-05-02 20:15:16 -07:00
pezcode
2fb67a707b
Vulkan: occlusion queries, housekeeping (#2505)
* Cleanup

* Request host-cached memory for readback

* Request device-visible memory for the uniform buffer

* Use more fine-grained image memory barrier stages

* Don't rebind vertex and index buffers if not necessary

* Timer queries

* Don't transition images during a renderpass

* Cache descriptor sets

* Trigger RenderDoc capture if requested

* Fix invalid command buffer after surface recreation

* Perform clear and blit before compute

* Use init.debug to enable validation layers

...instead of always enabling them in debug config

* Only resolve framebuffer once

* Report number of primitives without index buffer

* Minimize state changes

* Occlusion queries

* Transition swapchain image from undefined layout

* Make sure we have a combined graphics and compute queue family

Existing code already makes that assumption, otherwise we'd need different command queues and explicit resource queue transitions. The spec also guarantees that a device with such a queue family should exist.

* Release cached image views on texture destruction

* Fix stencil-only clear

* Fix non-zero integer format clear

* Annotate all optional functions with their extensions

* Support for BGFX_SAMPLER_SAMPLE_STENCIL

* Remove unused extension functions

* Support for BGFX_SAMPLER_BORDER_COLOR

* Undo descriptor set cache

Try this again in another PR... the hashing doesn't quite work with some bind combinations, and the cache needs a better eviction strategy

* Don't start renderpass for empty draw calls

* Advertize graphics debugger, if present

ie. RenderDoc

* Cleanup

* Only enable required features and extensions

* Don't spam warning about swapchain format fallback

* Cleanup
2021-05-02 20:09:33 -07:00
James Fulop
43db77159d
fix unintialized memory (#2499)
this then caused `DX_RELEASE(m_msaaRt, 0);` in `error:` to fire an assert since it tries to deref the garbage ptr
2021-04-29 17:46:24 -07:00
Бранимир Караџић
9310d19141 Cleanup. 2021-04-27 09:18:22 -07:00
Бранимир Караџић
d01f86a6a9 Cleanup. 2021-04-26 19:54:58 -07:00
Бранимир Караџић
c319aa909e Fixed build. 2021-04-23 22:30:21 -07:00
SnapperTT
ffde01f8c9
Fix change in blend rgba not being detected as a state change (#2494) 2021-04-23 20:15:01 -07:00
Бранимир Караџић
117c999d6e Added bgfx::Init capabilities mask. 2021-04-22 20:18:48 -07:00
pezcode
87855128bb
Vulkan: merge shared shader bindings (#2492) 2021-04-22 12:09:54 -07:00
pezcode
8e76e5e85c
Vulkan: multiple windows, capture support (#2491)
* Use correct aspect masks for stencil-only textures

* Make vkEnumerateInstanceVersion optional

This makes init not abort on Vulkan 1.0

* Move swapchain into FrameBufferVK

* Remove duplicate render pass creation code

* Manually resolve MSAA backbuffer

not guaranteed to be supported, but reduces resolve operations from 2 * (num views using backbuffer) to 1

* Support for multiple windows (BGFX_CAPS_SWAP_CHAIN)

* Capture support (BGFX_RESET_CAPTURE)

* Display present timings

* Recreate surface if native window handle changed

* Delayed swapchain deletion on resize

no more vkDeviceWaitIdle

* Recreate surface if BGFX_RESET_HIDPI is toggled

* Don't recreate swapchain if only the MSAA sample count changed

* Some extra caps checks

* Configurable backbuffer depth format

* Configurable backbuffer color format
2021-04-21 18:41:49 -07:00
Hugo Amnov
9320a20e72
WebGPU: Don't need bindings backward compatibility (#2488) 2021-04-21 12:17:55 -07:00
Hugo Amnov
ec36cf9872
Simplify SPIRV bindings shifts (shaderc bin version 11) (#2487) 2021-04-21 09:33:12 -07:00
Hugo Amnov
9695c0b155
WebGPU: Update to Attachments changes (#2485) 2021-04-21 07:39:38 -07:00
Hugo Amnov
24be4a38d0
WebGPU: Add texture format to shaderc (bin version 10) + streamline storage Images in shaders (#2482)
* WebGPU: Add texture format (shaderc bin version 10)

* WebGPU: Simplify storage images + Fix format decorations

* Shaderc: Cleanup Texture name assumption in textures
2021-04-20 20:18:49 -07:00
pezcode
e8d4b3dcce
Fixes for multiple windows and example 22 (#2483) 2021-04-19 15:30:03 -07:00
Hugo Amnov
cf8ff18263
WebGPU update (#2477)
* WebGPU: Update to latest changes + Fixes

* WebGPU: Fix RG11B10F format as framebuffer
2021-04-18 11:39:52 -07:00
Hugo Amnov
d8ef330967
Fix embedded shaders compilation (#2475) 2021-04-18 11:38:51 -07:00
Бранимир Караџић
e3f91f2895 Updated version number. 2021-04-17 08:36:19 -07:00
Бранимир Караџић
6a5ab30c6c In debug build assert on texture and frame buffer validation. 2021-04-17 08:35:34 -07:00
Бранимир Караџић
6109697ade Added bgfx::isFrameBufferValid API. 2021-04-16 22:13:26 -07:00
Бранимир Караџић
41df93f81d Cleanup. 2021-04-16 22:05:08 -07:00
pezcode
9e025301a9
Vulkan: add headless and MSAA backbuffer support (#2472)
* Swapchain class

* Headless support

* MSAA backbuffer

* Fix framebuffer resolve

layout transitions were missing and framebuffer mips and layers weren't used

* Fix blit with MSAA resolve source

only the main texture layout was transitioned

* Fix pipeline hash
2021-04-16 09:54:37 -07:00
Daniele Bartolini
83039433ee
Add textureSize() overloads for BgfxI/USampler2D (#2471) 2021-04-15 14:24:42 -07:00
Бранимир Караџић
0ff10648b6 Cleanup. 2021-04-13 20:30:14 -07:00
Matt Tytel
c6e17db9d6
Retain reset flags when creating a new metal frame buffer for a window. (#2469) 2021-04-12 12:42:53 -07:00
pezcode
900afe7644
GL: only unbind instance buffer if it changed (#2463) 2021-04-09 09:36:21 -07:00
pezcode
2240c591a1
Vulkan: ignore unused storage buffers (#2460) 2021-04-08 20:26:17 -07:00
pezcode
b298851bf0
Vertex buffer fixes (#2458)
* Vulkan: calculate vertex count from all streams, not just the first

...which might not exist in the first place

* Vulkan: use correct vertex stream offsets and handles

* D3D11: remember stream vertex count when no index buffer is bound
2021-04-08 10:28:42 -07:00
pezcode
cb49df3bca
Bind IMAGE2D_RO correctly as a texture2D without a sampler (#2454) 2021-04-07 20:05:17 -07:00
pezcode
870d14110b
Vulkan: allow writing to gl_FragColor without framebuffer color attachment (#2452) 2021-04-07 07:21:02 -07:00
Бранимир Караџић
9582f19483 Removed assert when viewport is zero size. 2021-04-05 16:07:23 -07:00
Бранимир Караџић
d61f78e263 Cleanup. 2021-04-05 12:27:48 -07:00
pezcode
db12a1d0e1
Vulkan: alias texture types in shaders + misc fixes (#2447)
* Don't enable optional extensions if BGFX_CONFIG_RENDERER_USE_EXTENSIONS is 0

* Support rendering to slices of 3D textures

* Create transient command pool

* Blit array layers for non-cube textures

* Clean up destroy and release functions

Simplifies CommandQueueVK code, automatically sets handles to NULL after release(), removes the need for explicit StateCacheT instantiations, and enables usage of StateCacheLru

* Fix renderpass hash calculation

* Allow sampling cube array textures

* Make StateCacheLru work with types overloading the address-of operator

* Alias textures to shader sampler type

Requires shaders with shaderc binary version 8 or higher

* Fix 32-bit compilation
2021-04-05 07:40:15 -07:00
pezcode
9d09088488
Additional framebuffer validation (#2448) 2021-04-05 07:23:25 -07:00
Бранимир Караџић
517942f8e1 Cleanup. 2021-04-02 20:17:42 -07:00
Бранимир Караџић
45c0b29470 Cleanup. 2021-04-02 16:46:42 -07:00
Paul Gruenbacher
3b34b6e68a
Update bgfx_p.h (#2444)
If you do 
```
bgfx::setIndexBuffer()
bgfx::submit(BGFX_DISCARD_NONE)
bgfx::submit()
```

then the second submit will be broken because even though it still uses the correct index buffer it will lose the BGFX_SUBMIT_INTERNAL_INDEX32 state.
Basically all multi-pass calls involving a 32index buffer are broken currently in bgfx master. 
This fixes bug introduced by 5c304dad3b
2021-04-02 16:43:52 -07:00
Бранимир Караџић
0df2e90edb Cleanup. 2021-04-01 20:09:16 -07:00
Vladimir Vukicevic
cb77d3bb46
Fix crash when hitting max draw call limit (#2440)
* Expand instancing demo to have non-instanced path

* Fix count vs. index off by one error when hitting max draw calls
2021-04-01 19:03:01 -07:00
pezcode
e38920c07b
View rect/scissor and framebuffer validation (#2439)
* Crop view rect and scissor to frame-/backbuffer size

* Validate framebuffer attachments

Check texture size, mip, layer range, layer count mismatch

* Remove framebuffer check from Vulkan backend

* Fix layer check for 3D attachment

* Cleanup
2021-04-01 16:18:09 -07:00
Christophe Dehais
2433b598e7
Fix BGFX_STATE_FRONT_CCW flag being ignored in DX12 and VK (#2438) 2021-04-01 08:47:45 -07:00
simon chen
0b8677ed06
fix update bug when compressed texture create with BGFX_TEXTURE_SRGB (#2437)
Co-authored-by: chenmou.cm <chenmou.cm@alibaba-inc.com>
2021-03-30 19:50:19 -07:00
C. M. Barth
f218d7ed13
Support dynamic SwapChainPanel changes for DirectX11 UWP scenarios (#2422)
* remove swap chain from consumer

* fix swap chain cleanup

* renderer workaround

* cleanup changes around platform data

* only update swapchainpanels

* revert spacing

* favor NULL over nullptr
2021-03-08 15:13:04 -08:00
pezcode
02e4786e04
Vulkan: fix sync hazards (#2419)
- write-after-write when blitting to the same image
- missing barrier between compute dispatches if a view has no draws
2021-03-06 18:56:55 -08:00
Бранимир Караџић
b3dcc83d66 Fixed warning. 2021-03-04 19:09:10 -08:00
Бранимир Караџић
38a559ea89 Fixed build. 2021-03-04 10:01:42 -08:00
Бранимир Караџић
cf1d24cb38 Fixed OSX build. 2021-03-04 09:57:28 -08:00
Бранимир Караџић
104a20754c VK: Enabled VK_EXT_line_rasterization. 2021-03-03 16:56:19 -08:00
pezcode
28be8bba61
Vulkan extension detection fix (#2418)
* Fix variable naming

* Check if VK_KHR_get_physical_device_properties2 is actually supported

* Fix extension detection logic

Device extension data wasn't cleared after enumerating each physical device, essentially checking if ANY device supports that extensions, not just the selected device
2021-03-03 16:55:01 -08:00
Бранимир Караџић
998947d58c VK: Disabled VK_EXT_line_rasterization. 2021-03-03 12:10:50 -08:00
Бранимир Караџић
696ab702fe Merge branch 'master' of github.com:bkaradzic/bgfx 2021-03-03 08:28:11 -08:00
Бранимир Караџић
3dd78ef893 Cleanup. 2021-03-03 08:27:57 -08:00
Бранимир Караџић
e30c32ed86 Fixed GCC errors & warnings. 2021-03-02 18:26:44 -08:00
pezcode
f9679fde50
Misc. Vulkan features and fixes (#2417)
* Vulkan: add conservative rasterization

* Vulkan: check device features for caps and state

* Vulkan: add line AA

* Don't assert in init()

* Vulkan: fix swapchain reset logic and handle lost surface

* Vulkan: report dedicated memory info in Stats

* Vulkan: fix sRGB backbuffer pipeline hash

* Vulkan: check BGFX_RESET_SUSPEND
2021-03-02 18:23:55 -08:00
Бранимир Караџић
58f0d55612 Cleanup. 2021-02-28 18:59:05 -08:00
pezcode
ece0c4e1a1
Vulkan: ignore BGFX_CLEAR_STENCIL if depth attachment has no stencil (#2413) 2021-02-28 15:16:19 -08:00
Branimir Karadžić
8e75b38207 Don't include compute on HLSL 3 and below. 2021-02-28 13:41:16 -08:00
pezcode
302c978b1d
Make shaderc output independent of backend enums (#2411)
* Fix typo in SPIR-V id

* Use backend-agnostic shaderc output

...as opposed to directly storing and comparing against Vulkan and WebGPU enums. This is backwards-compatible with existing code and shaders.

* Remove comments and Undefined value
2021-02-28 12:38:12 -08:00
Branimir Karadžić
005d119cae Fixed MinGW warning. 2021-02-26 18:48:43 -08:00
pezcode
9999d43374
Vulkan: fix scratch buffer size calculation (#2409) 2021-02-26 11:40:38 -08:00
Бранимир Караџић
e4d2451993 Made Vulkan default renderer backend on Linux. 2021-02-25 19:44:37 -08:00
Branimir Karadžić
befe56f947 Fixed crash when program doesn't have fragment shader. 2021-02-25 19:00:54 -08:00
Бранимир Караџић
f5cdf6e4bf Cleanup. 2021-02-25 18:40:30 -08:00
pezcode
8d51de5c5d
Various Vulkan fixes (#2408)
* Vulkan: query max anisotropy

...instead of hardcoding it to 4

* Vulkan: use BGFX_CONFIG_MIP_LOD_BIAS

* Vulkan: consider BGFX_CONFIG_PREFER_DISCRETE_GPU at device selection

* Vulkan: implement resizing for textures with backbuffer ratio size

* Vulkan: use correct framebuffer attachment layer and mip

* Vulkan: bind correct image mip

* Cleanup

* Vulkan: add indirect draw support

* Vulkan: add support for BGFX_DEBUG_WIREFRAME

* Vulkan: check all extensions and layers

... not just the first 64

* Vulkan: add support for VPRT

https://github.com/bkaradzic/bgfx/issues/2320
2021-02-25 14:31:18 -08:00
Бранимир Караџић
0afe0d2330 Cleanup. 2021-02-24 00:09:34 -08:00
Бранимир Караџић
8d622e4cfa Cleanup. 2021-02-23 21:16:07 -08:00
Бранимир Караџић
b157d15e43 Cleanup. 2021-02-23 12:54:14 -08:00
pezcode
fcc44dc107
Vulkan sync rewrite (#2402)
* Vulkan: allow setting image debug name

* Vulkan: record multiple frames ahead of the GPU

...instead of stalling on the CPU after each submit. Controllable with init.resolution.maxFrameLatency, same as the D3D11/12 backends.

* Vulkan: some additional checks at swapchain creation

* Vulkan: stall for screenshot

* Vulkan: move blit out of render pass

* Vulkan: deferred framebuffer deletion

* Vulkan: fix cubemap blit

* Cleanup

* Vulkan: storage image must have GENERAL layout and has no sampler

* Vulkan: use slightly more fine-grained barriers

* Vulkan: readTexture should stall, too

* Cleanup

* Vulkan: selective acquire

Don't acquire a swapchain image if no view renders to the backbuffer, avoiding stalls due to vsync or reaching the backbuffer limit

* Vulkan: deferred program and state cache deletion

* Vulkan: fix debug blit
2021-02-23 12:53:12 -08:00
Juan Carlos González Amestoy
8b209012b1
- Implemented BGFX_CAPS_SWAP_CHAIN in OpenGl on Macos (#2400) 2021-02-22 08:45:25 -08:00
Бранимир Караџић
efaa20b4a3 Cleanup. 2021-02-16 09:12:04 -08:00
Kitchen
966b4b8df2
fix update dynamic buffer with compute read flag only (#2394)
* fix resize buffer with compute read/write flag error

* only update dynamic buffer with compute read flag

Co-authored-by: chenjunjie <junjie020@163.com>
2021-02-16 09:06:46 -08:00
Бранимир Караџић
0cbc215c02 Cleanup. 2021-02-11 20:32:52 -08:00
pezcode
f983367d75
Vulkan synchronization fixes (#2386)
* Fix out of bounds index for unknown device types

* Vulkan: Insert barrier before image host reads

* Vulkan: Make commands wait for the wait semaphore

Making commands wait at BOTTOM_OF_PIPE is a no-op, resulting in instant execution

* Vulkan: Insert barrier between views/dispatches instead of waiting on the host

* Vulkan: Fix determination of access flag from image layout

This fixes two write-after-write races with copy commands after a layout transition to VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL

* Add BGFX_MAX_FRAME_LATENCY define

Affected backends either used a magic value of 3 or defined their own XX_MAX_FRAMES_IN_FLIGHT to be 3

* Vulkan: Include indirect draw in pipeline barrier

* Vulkan: honor init.resolution.numBackBuffers for swapchain size

* Make max frame latency configurable at compile time
2021-02-11 20:29:52 -08:00
Бранимир Караџић
f12eba6bc0 Updated version number. 2021-02-05 19:58:50 -08:00
Lee Thomason
176ab53d45
Print error messages when shader doesn't compile. (#2378)
* Trace compile error if shader doesn't compile.

* remove redundant output

Co-authored-by: Lee Thomason <leet@unity3d.com>
2021-02-05 17:12:01 -08:00
Бранимир Караџић
16f441758f Fixed #2368. 2021-01-25 12:24:12 -08:00
Бранимир Караџић
d8cfb8f64d Fixed issue #2368. 2021-01-22 07:33:59 -08:00
Hugo Amnov
a515dd3c3d
WebGPU update (#2364)
* Update WebGPU renderer to match new state of API

* Update WebGPU files
2021-01-19 15:18:30 -08:00
kingscallop
5a6c1361ce
Fix compute on Vulkan when there is only one buffer but no uniforms (#2359)
When using this compute shader, the following validation errors appear.
This patch fixes the issue.

BUFFER_WR(cBuffer, uint, 1);

NUM_THREADS(1u, 1u, 1u)
void main()
{
	cBuffer[0] = 0u;
}

../../../src/renderer_vk.cpp (628): BGFX ---E-       CommandBuffer,
Validation, 0: Validation Error: [
VUID-vkCmdBindDescriptorSets-dynamicOffsetCount-00359 ] Object 0: handle =
0x7fffe453ec88, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID =
0x82756c54 | vkCmdBindDescriptorSets(): Attempting to bind 1 descriptorSets
with 0 dynamic descriptors, but dynamicOffsetCount is 1. It should exactly
match the number of dynamic descriptors. The Vulkan spec states:
dynamicOffsetCount must be equal to the total number of dynamic descriptors
in pDescriptorSets
(https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/
vkspec.html#VUID-vkCmdBindDescriptorSets-dynamicOffsetCount-00359)

../../../src/renderer_vk.cpp (628): BGFX ---E-            Pipeline,
Validation, 0: Validation Error: [ VUID-vkCmdDispatch-None-02697 ] Object 0:
handle = 0xcd00000000cd, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle =
0x630000000063, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2:
VK_NULL_HANDLE, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID =
0xfd9e3152 | vkCmdDispatch(): VkPipeline 0xcd00000000cd[] defined with
VkPipelineLayout 0x630000000063[] is not compatible for maximum set
statically used 0 with bound descriptor sets, last bound with
VkPipelineLayout 0x0[] The Vulkan spec states: For each set n that is
statically used by the VkPipeline bound to the pipeline bind point used by
this command, a descriptor set must have been bound to n at the same
pipeline bind point, with a VkPipelineLayout that is compatible for set n,
with the VkPipelineLayout used to create the current VkPipeline, as
described in Pipeline Layout Compatibility
(https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/
vkspec.html#VUID-vkCmdDispatch-None-02697)

../../../src/renderer_vk.cpp (628): BGFX ---E-       CommandBuffer,
Validation, 0: Validation Error: [
UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotBound ] Object 0: handle
= 0x7fffe453ec88, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID =
0xcde11083 | VkPipeline 0xcd00000000cd[] uses set #0 but that set is not
bound.
2021-01-16 14:00:40 -08:00
kingscallop
758566b3af
Make the provoking vertex consistent across OpenGL, D3D and Vulkan (#2360)
The default provoking vertex on OpenGL is the last of a triangle, but
on D3D and Vulkan it is the first.

This patch sets the provoking vertex to the first vertex on OpenGL.
2021-01-16 13:59:28 -08:00
kingscallop
26c3768cac
Fix typo in bgfx_shader.sh (#2361) 2021-01-16 13:58:32 -08:00
Бранимир Караџић
af49c5d264 Happy New Year! 2021-01-14 15:53:49 -08:00
Бранимир Караџић
b6ae2d2709 Cleanup. 2021-01-10 14:44:30 -08:00
Alex-MSFT
68f79970e1
Don't skip reset if platform data has changed. (#2347)
(cherry picked from commit 8c4cc84c62)
2021-01-07 16:56:57 -08:00
MooZ
d65dac2000
Shaderc OpenGL fixes. (#2317)
* Reworked profile cli argument.

* Added missing GLSL profile.

* Fixed essl shader preambule.

* Fixed uniform "parsing" and hlsl profiles.

* Reworked hlsl profiles.

* Fixed missing extension for gl_FragDepth.

* Cleanup.

* Removed version preamble and reverted shadow samplers translation.

* Fixed HLSL profile tests.
2020-12-28 11:24:49 -08:00
Бранимир Караџић
534733fe3c Cleanup. 2020-12-21 09:07:33 -08:00
Antti Heinonen
40259e35f8
DX11: Fix draw vertex count not updating (#2337) 2020-12-21 09:05:04 -08:00
Бранимир Караџић
4967c29c14 Added missing caps to debug output. 2020-12-20 11:06:40 -08:00
Branimir Karadžić
7fe9e83393 Cleanup. 2020-12-17 19:30:38 -08:00
Бранимир Караџић
6f16d0e68c Cleanup. 2020-12-16 21:17:49 -08:00
Бранимир Караџић
2b99e3e5cb Updated version number. 2020-12-16 21:12:16 -08:00
Бранимир Караџић
db54d046e4 Cleanup. 2020-12-16 20:28:57 -08:00
Бранимир Караџић
600c7798fd Removed BGFX_CAPS_INDEX32 from D3D9. Added validation for BGFX_CAPS_INDEX32 support. 2020-12-15 20:23:01 -08:00
Branimir Karadžić
5c304dad3b Fixed issue #2330. Added support for 32-bit indices in transient index buffer. 2020-12-15 19:01:25 -08:00
attilaz
2bc35df070
Fixed metal screenshot sync issue (#2327) (#2329) 2020-12-14 12:26:08 -08:00
Cedric Guillemet
2556e68724
fix STAT wrong chunk copy (#2328)
Co-authored-by: Cedric Guillemet <ceguille@microsoft.com>
2020-12-14 10:31:16 -08:00
Бранимир Караџић
796acfa98b Added Attachment.numLayers needed for viewport layer array support. 2020-12-12 10:04:14 -08:00
Бранимир Караџић
23db05b990 DXGI: Disabled DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT since support for it is not implemented correctly. 2020-12-07 09:36:34 -08:00
Бранимир Караџић
4568dd7f89 Updated version number. 2020-12-02 21:08:35 -08:00
Бранимир Караџић
0714e7c41e Cleanup. 2020-12-01 21:58:01 -08:00
Бранимир Караџић
ab03a8ae60 Cleanup. 2020-11-30 22:14:05 -08:00