280 Commits

Author SHA1 Message Date
Branimir Karadžić
90d61887ac D3D11: Renamed dx11 to dxbc. (#3586) 2026-02-08 01:45:18 +00:00
Branimir Karadžić
252efb73d9 Rebuilt 16-shadowmaps shaders. (#3584) 2026-02-08 00:41:24 +00:00
Branimir Karadžić
8b13337c6f d3d4linux: Added binaries. (#3581) 2026-02-06 16:32:04 +00:00
Quaylyn Rimer
6187b36185 Feature/d3d4linux integration (#3578)
* Add d3d4linux to 3rdparty for Linux HLSL shader compilation

- Added d3d4linux wrapper library for D3DCompiler access on Linux
- Includes Microsoft D3DCompiler DLLs (versions 43 and 47)
- Source from https://github.com/samhocevar/d3d4linux
- Commit: c9b1ca9 (Handle D3DReflect() regardless of DLL version)
- Enables HLSL shader cross-compilation on Linux via Wine

This is the first step toward implementing issue #1869:
Enable DirectX shader compilation on Linux platforms without
requiring Windows machines in the build pipeline.

Components included:
- d3d4linux.cpp - Wine-based D3DCompiler wrapper
- d3dcompiler_43.dll & d3dcompiler_47.dll - MS compiler DLLs
- Header files for D3D API compatibility
- Makefile for building the wrapper library
- Test files for validation

* Fix d3d4linux struct alignment for D3DReflect compatibility

- Add D3D_MIN_PRECISION enum to d3d4linux_enums.h
- Add MinPrecision field and padding to D3D11_SIGNATURE_PARAMETER_DESC
- Fixes struct size mismatch (32 bytes -> 40 bytes) with d3dcompiler_47.dll
- All 4 D3D functions now work: D3DCompile, D3DReflect, D3DStripShader, D3DDisassemble
- Add implementation_log.md documenting the integration process

Part of issue #1869: Enable HLSL shader compilation on Linux via Wine

* Integrate d3d4linux with bgfx shaderc for Linux HLSL compilation

Add support for HLSL shader compilation on Linux via d3d4linux (Wine-based).
This enables building D3D11/D3D12 shaders on Linux without Windows.

Changes:
- shaderc.h: Add SHADERC_CONFIG_HLSL_D3D4LINUX option to enable HLSL on Linux
- shaderc_hlsl.cpp: Add d3d4linux code path with conditional compilation
  - Uses d3d4linux inline functions instead of Windows DLL loading
  - load() returns d3d4linux compiler info on Linux
  - unload() is no-op on d3d4linux (no DLL to close)
- shaderc.lua: Add d3d4linux include path for Linux/macOS builds

Usage:
  Build with -DSHADERC_CONFIG_HLSL_D3D4LINUX=1
  Set D3D4LINUX_WINE, D3D4LINUX_EXE, D3D4LINUX_DLL environment variables

Requires: Wine, d3d4linux.exe, d3dcompiler_47.dll

Part of issue #1869: Enable HLSL shader compilation on Linux

* d3d4linux: Complete shaderc HLSL integration with Wine

Full working HLSL shader compilation on Linux via d3dcompiler_47.dll and Wine.

d3d4linux fixes:
- Add D3D_MIN_PRECISION enum and MinPrecision field to D3D11_SIGNATURE_PARAMETER_DESC
  (fixes struct size mismatch: 32 bytes -> 40 bytes to match Windows ABI)
- Add missing D3DCOMPILE_* flags used by shaderc
- Add ID3D11ShaderReflectionType struct with GetType() support
- Wine 11+ compatibility: default path changed from wine64 to wine with fallback
- Fix D3DDisassemble IPC protocol bug (only write comment string when present)

shaderc integration:
- Add SHADERC_CONFIG_HLSL_D3D4LINUX=1 define for Linux/macOS builds
- Restructure shaderc_hlsl.cpp with conditional compilation for d3d4linux vs Windows
- Fix null pointer crash when D3DCompile returns error without message
- Initialize ID3DBlob pointers to NULL

Usage:
  D3D4LINUX_EXE=/path/to/d3d4linux.exe shaderc -f shader.sc -o out.bin \
    --type vertex --platform windows -p s_5_0

Tested with vs_cubes.sc, fs_cubes.sc, vs_bump.sc - all compile successfully.
D3DCompile, D3DReflect, D3DStripShader, D3DDisassemble all working.

Implements: bkaradzic/bgfx#1869

* docs: Add d3d4linux documentation

- docs/d3d4linux-shaderc-support.md: User guide explaining prerequisites,
  installation, usage, environment variables, and troubleshooting for
  compiling HLSL shaders on Linux/macOS via Wine

- implementation_log.md: Updated with shaderc integration completion details,
  including all code changes made, test results, and commit references

* docs: Add EditorConfig/eclint notes to implementation log

Documents that eclint reports some style issues in modified files, but these
are pre-existing in the original codebase (copyright header comments using
spaces, line length in shaderc files). Our changes follow the existing code
style and do not introduce new violations.

* Fix d3d4linux integration after rebase onto upstream master

This commit fixes build issues that arose after rebasing onto the updated
upstream master which includes the TINT library and directx-headers.

Changes in this commit:

## shaderc.h
- Disable DXIL (DXC compiler) when d3d4linux is enabled
  - DXIL uses DirectX Compiler (DXC) which requires directx-headers
  - d3d4linux uses D3DCompiler via Wine which is a different compilation path
  - These two approaches are mutually exclusive on Linux

## shaderc.lua
- Removed directx-headers include paths for Linux builds
  - d3d4linux provides its own D3D type definitions
  - directx-headers conflicts with d3d4linux headers (duplicate typedefs)

## shaderc_hlsl.cpp
- Made all D3D-related includes conditional on SHADERC_CONFIG_HLSL_D3D4LINUX
  - Use <d3d4linux.h> when d3d4linux is enabled
  - Use <d3dcompiler.h> and <d3d11shader.h> on Windows
  - PFN_D3D_* function pointer typedefs (use WINAPI calling convention)
  - D3DCompiler struct with IID_ID3D11ShaderReflection member
  - s_d3dcompiler[] array of DLL versions
  - s_d3dcompilerdll handle
- Added simplified D3DCompiler struct for d3d4linux path (fileName only)
- Fixed D3DReflect call to use d3d4linux's integer IID macro

## Testing
- Successfully compiled shaderc with SHADERC_CONFIG_HLSL_D3D4LINUX=1
- Successfully compiled vs_cubes.sc to D3D11 bytecode (DXBC format)
- Output verified with xxd showing VSH header and DXBC signature

* Cleanup d3d4linux integration per maintainer feedback

Simplified changes:
- Remove SHADERC_CONFIG_HLSL_D3D4LINUX define, use BX_PLATFORM_* directly
- SHADERC_CONFIG_HLSL now enabled on Windows/Linux/macOS
- SHADERC_CONFIG_DXIL now Windows-only (DXC needs native D3D)

Removed files:
- d3d4linux test files (compile-hlsl.cpp, ps_sample.hlsl)
- d3d4linux extras (UE4 patches)
- d3d4linux.Build.cs (UE4 build file)
- d3dcompiler_43.dll (only 47 needed)
- implementation_log.md
- docs/d3d4linux-shaderc-support.md

Build and test verified on Linux with Wine 11.0.

* Enable DXIL on Linux/macOS and configure d3d4linux paths

Changes:
- shaderc.h: Enable SHADERC_CONFIG_DXIL on Linux and macOS (previously Windows-only)
  This allows Shader Model 6.0+ compilation via DXC on non-Windows platforms

- shaderc.lua: Configure d3d4linux and directx-headers for Linux/macOS
  - Add directx-headers include paths for DXIL support
  - Add WSL stubs include path for COM compatibility types
  - Define D3D4LINUX_EXE path pointing to 3rdparty/d3d4linux/d3d4linux.exe
  - Define D3D4LINUX_DLL path for d3dcompiler_47.dll (Wine Z: drive prefix)

Prerequisites for HLSL compilation on Linux:
1. Wine installed (/usr/bin/wine or /usr/bin/wine64)
2. Build d3d4linux.exe: cd 3rdparty/d3d4linux && make
   (requires mingw-w64 cross-compiler: x86_64-w64-mingw32-c++)
3. d3dcompiler_47.dll in 3rdparty/d3d4linux/

Tested: SM 5.0 vertex shader compilation works via Wine/d3d4linux
DXIL (SM 6.0+) requires native DXC library installation

* Remove macOS from DXIL config (no DXC library available)

Microsoft's DXC releases only include:
- Windows: dxcompiler.dll
- Linux: libdxcompiler.so

There is no libdxcompiler.dylib for macOS. Updated SHADERC_CONFIG_DXIL
to only enable DXIL on Windows and Linux.

macOS still supports legacy HLSL (SM 5.0) via d3d4linux.

* Remove d3d4linux build files from bgfx repo

Users should obtain d3d4linux.exe and d3dcompiler_47.dll from:
https://github.com/killerdevildog/d3d4linux

Only headers are needed for bgfx compilation.

* Fix d3d4linux reflection: deserialize D3D11_SHADER_TYPE_DESC

Fixes uniform extraction bug where type info was not being read from
the IPC stream. This is required for bgfx to properly determine uniform
types and array element counts via findUniformType().

* Add d3d4linux source with reflection serialization fix

Include d3d4linux.cpp and Makefile with fixes for D3D11_SHADER_TYPE_DESC
serialization. This allows building shaderc with proper uniform extraction
while upstream PR is pending: https://github.com/samhocevar/d3d4linux/pull/1

* Apply maintainer cleanup: unified code paths and header guards

* Force D3D_SVF_USED flag on all uniform variables

This forces all uniform variables to be marked as 'used' during reflection
deserialization, ensuring bgfx extracts type info for all uniforms.

Note: This deviates from native D3D compiler behavior where unused uniforms
do not have the D3D_SVF_USED flag set. Native behavior would skip extraction
for uniforms not actually referenced in shader code.

* Fix D3DDisassemble serialization mismatch

Only write comment string when szComments is non-null to match
server-side read behavior. Fixes 'bad message received' error.

* shaderc: Improve d3d4linux integration and error handling

This commit enhances the d3d4linux integration for HLSL shader compilation
on Linux and macOS platforms with several key improvements:

Key Changes:
- Dynamic path detection for d3d4linux binaries instead of hardcoded paths
- Relocate d3dcompiler_47.dll from 3rdparty/d3d4linux/ to tools/bin/windows/
- Remove d3d4linux.exe from 3rdparty (now managed separately)
- Improved error handling with proper null checks and user feedback
- Enhanced logging using BX_TRACE for consistency
- Remove --verbose flag from shader compilation make rules for cleaner output
- Automatic environment variable setup (D3D4LINUX_EXE, D3D4LINUX_DLL)

Technical Details:
- shaderc_hlsl.cpp now dynamically locates d3d4linux.exe and d3dcompiler_47.dll
  relative to the executable directory
- Proper error messages when required files are not found
- Simplified Makefile in 3rdparty/d3d4linux/
- Removed hardcoded D3D4LINUX_EXE and D3D4LINUX_DLL defines from shaderc.lua

Files Modified:
- 3rdparty/d3d4linux/Makefile: Simplified build rules
- scripts/shader.mk: Removed --verbose flags from compilation commands
- scripts/shaderc.lua: Removed hardcoded path defines
- tools/shaderc/shaderc_hlsl.cpp: Enhanced d3d4linux integration logic

Files Deleted:
- 3rdparty/d3d4linux/d3d4linux.exe
- 3rdparty/d3d4linux/d3dcompiler_47.dll

This improves portability and makes the build system more maintainable
by removing hardcoded paths and improving runtime binary discovery.

Credit: bkaradzic provided patch

* Delete d3d4linux.md

* Delete examples/runtime/shaders/dx11/vs_cubes.bin

* Remove macOS.

---------

Co-authored-by: Branimir Karadžić <branimirkaradzic@gmail.com>
2026-02-06 16:28:04 +00:00
Branimir Karadžić
33541e4bab D3D12: Added DXIL support. (#3558)
* Added DXIL support.

* Fixed Linux build.

* Fixed mingw build.

* Fixed build.
2026-01-20 01:43:31 +00:00
Branimir Karadžić
cc923c5165 Update Тint (#3553)
* Trimmed Tint.

* Updated Tint.
2026-01-16 04:44:27 +00:00
Branimir Karadžić
967f7629b6 Added WGSL shaders. (#3543) 2026-01-10 03:31:01 +00:00
Branimir Karadžić
509129b5d7 Rebuild shaders (#3537)
* shaderc: Removed instMul.

* Rebuilt shaders.
2026-01-09 06:41:06 +00:00
Бранимир Караџић
67b4d14376 Rebuilt HLSL shaders. 2025-12-26 00:23:54 -08:00
Branimir Karadžić
9d63c39a44 Rebuilt shaders. (#3520) 2025-12-23 04:53:36 +00:00
Бранимир Караџић
8f3b56c3e4 Added vk_layer_settings.txt. 2025-10-27 10:20:24 -07:00
Бранимир Караџић
56dd9f4ae1 Rebuilt metal & spir-v shaders. 2025-05-10 19:58:27 -07:00
Бранимир Караџић
fdf84449ef Rebuilt metal & spir-v shaders. 2025-03-14 22:05:19 -07:00
Aaron Franke
40961806bd Format files to remove trailing spaces (#3384) 2024-12-09 22:01:16 -08:00
Бранимир Караџић
f8b20616de Rebuilt spir-v shaders. 2024-09-28 10:14:37 -07:00
Branimir Karadžić
d1feabe319 Rebuilt shaders. 2024-06-15 14:47:08 -07:00
Бранимир Караџић
00fa5ad179 Updated SPIR-V shaders. 2024-05-27 22:32:47 -07:00
Бранимир Караџић
edb72488bc macOS: Fixed VK (MoltenVK 1.2.6). 2023-12-01 20:51:28 -08:00
Branimir Karadžić
c54063b88c Updated texture. 2023-11-08 07:14:30 -08:00
Branimir Karadžić
1e800e8ba9 Rebuilt assets. 2023-11-06 21:37:19 -08:00
Бранимир Караџић
f14c14a485 Removed D3D9. (#3191) 2023-11-03 21:15:42 -07:00
Branimir Karadžić
6f2716d2f4 Rebuilt shaders. 2023-09-30 16:54:57 -07:00
Бранимир Караџић
d909d01734 Metal: Rebuilt shaders. 2023-04-12 19:23:57 -07:00
Бранимир Караџић
6a03a1ec5e Rebuilt Metal shaders. 2022-10-29 09:17:29 -07:00
Бранимир Караџић
0069766e61 Rebuilt SPIR-V shaders. 2022-10-29 09:03:13 -07:00
Бранимир Караџић
f8af71c4ce Rebuilt SPIR-V shaders. 2022-10-27 19:44:24 -07:00
Raziel Alphadios
c2bc5177b5 Add support for remaining unsupported ASTC formats (#2963)
* Add support for remaining unsupported ASTC formats
Add new ASTC formats into pixelformats example and ninja scripts
Rebuild ASTC textures

* Update idl and generate
Move comma in pixelformats

Co-authored-by: Raziel Alphadios <raziely@gmail.com>
2022-10-25 17:03:40 -07:00
pezcode
ba467be036 Add support for indirect draw with indirect count (#2925)
* Add indirect draw with indirect count (BGFX_CAPS_DRAW_INDIRECT_COUNT)

* Update bindings

* VK: Add support for BGFX_CAPS_DRAW_INDIRECT_COUNT

* D3D12: Add support for BGFX_CAPS_DRAW_INDIRECT_COUNT

* GL: Add support for BGFX_CAPS_DRAW_INDIRECT_COUNT

* 48-drawindirect: Use BGFX_CAPS_DRAW_INDIRECT_COUNT if available

* 48-drawindirect: Update shaders
2022-09-17 18:16:19 -07:00
blackhole
2b11045331 Example 49 - hextile (Changes to fix regular tiling (tiling rate) to match hex tile rate) (#2924) 2022-09-16 13:48:19 -07:00
blackhole
a8a10b0b89 Adds example 49-hextile (#2922)
* First commit - tested with dx11 on windows

* Minor changes & adding some comments.

* Update hextile.cpp

* update some bin files

* rename texture

* minor comment update

* Added support to configure tile rate as well as tile rotation strength, update bin files & screenshot

* use texture from polyhaven, updated screenshot, updated bin files & minor changes to shader.

* missed pushing texture

* update license

* Update hextile.cpp

* Fix regular tiling

* use ktx with mipmaps

* minor change to ensure that regular tiling & hextile matches with default tile rate.

* minor c

Co-authored-by: Бранимир Караџић <branimirkaradzic@gmail.com>
2022-09-15 19:03:07 -07:00
SnapperTT
4613bd1e02 Parallelised compute shader in example 48 (#2906)
* Parallelised compute shader in example 48

* Ex48 - Dispatch numToDraw/64 workgroups of 64 local threads

* fixed vs build (again)
2022-08-29 06:44:55 -07:00
SnapperTT
135dc7fa27 Adds example 48-multidrawindirect (#2894)
* Added example 48-multidrawindirect

* Added example 48-multidrawindirect

* enable shader.mk to build directories that only have compute shaders

* compiled shaders for example 48

* MultidrawIndirect example renamed to DrawIndirect, sets draw mtx in compute

* update 48-drawindirect shaders

* fix typos

* fixed bgfx::setPlatformData change for example48

* fix docs

* added name to cs_drawindirect.sc

* style updates for example 44

* add slider to example 48-drawindirect
2022-08-26 21:32:15 -07:00
Michał Cichoń
c8c245c37b pixelformat: Include compressed format in texture sets (#2893)
* pixelformat: Include compressed format in texture sets

* pixelformats: Show why texture preview is not shown
2022-08-25 06:51:48 -07:00
Michał Cichoń
549077fc0b Pixelformats example mupltiple sources (#2889)
* Added texture conversion for pixelformat to runtime asset.

* pixelformats: Support multiple sources, cleanup
2022-08-23 12:51:00 -07:00
Бранимир Караџић
664bb5ca21 39-assao: Rebuilt spir-v shaders. 2022-05-25 09:24:31 -07:00
Бранимир Караџић
04318d22c1 Rebuilt shaders. 2022-03-26 13:46:02 -07:00
Aleš Mlakar
130bc00608 shaderc: Ignore .@data uniforms when compiling for metal (#2677)
Co-authored-by: Aleš Mlakar <ales.ambits@gmail.com>
2021-12-06 09:39:05 -08:00
Бранимир Караџић
73acc9e59b 41-tess: Updated GL shaders. 2021-11-21 07:58:19 -08:00
Branimir Karadžić
1d0d9b7149 21-deferred: Rebuilt shaders. 2021-10-28 18:40:46 -07:00
Branimir Karadžić
4f1b3f8a1b 37-gpudrivenrendering: Rebuilt shaders. 2021-10-22 11:33:10 -07:00
Branimir Karadžić
778dffb6ee 46-fsr: Built shaders. 2021-10-06 17:40:15 -07:00
Бранимир Караџић
f50d84da52 Rebuilt SPIR-V shaders. 2021-10-02 11:31:52 -07:00
Branimir Karadžić
daa4f9d627 Updated shaders. 2021-05-18 20:36:03 -07:00
Бранимир Караџић
3214539bad Fixing WebGL + Android instancing. 2021-05-18 20:22:46 -07:00
Branimir Karadžić
3e30d7f42f Updated shaders. 2021-02-04 20:35:37 -08:00
Branimir Karadžić
820e0a0e03 Updated shaders. 2021-02-04 20:33:42 -08:00
Branimir Karadžić
1401a5333d 45-bokeh: Built shaders and added example. 2021-01-31 10:07:49 -08:00
Branimir Karadžić
4c18b80c9d 44-sss: Built shaders and added example to GENie script. 2021-01-10 11:24:28 -08:00
Branimir Karadžić
4760628bb1 43-denoise: Added shaders. 2021-01-02 10:46:43 -08:00
Бранимир Караџић
c2b7ffe2e7 Updated SPIR-V and Metal shaders. 2020-12-28 13:01:44 -08:00