Comments (10)
(As a side note ), I think there is a small error in shaderc documentation.
-p, --profile Shader model (f.e. ps_3_0).\n"
The line above suggest that you can use either -p or --profile to define the shader model.
However, only the "-p" keyword is valid. "--profile" seems to be only checked at the beginning.
See f.e. shaderc.cpp line 552. in( compileHLSLShaderDx9 ).
(I may have overlooked something but if I try to use the "profile" keyword, shaderc ask me to declare a profile so ...)
from bgfx.
The best way to setup shader compiling is by using makefile. It does everything you need, you just call make TARGET=<#> to compile for target platform. See:
https://github.com/bkaradzic/bgfx/blob/master/examples/01-cubes/makefile
It uses:
https://github.com/bkaradzic/bgfx/blob/master/premake/shader.mk
I'm going to look -p, --profile inconsistency you mentioned.
from bgfx.
Fixed 391ebae
from bgfx.
The makefile works fine. Thanks a lot :)
In the meantime, I ported it to premake so that a single build system ca be used. (it also ease deployment)
(E.g. make shader compilation a part of the projects generation pass)
In case you are interested, it's there:
see: bgfx_compile_shader.lua
https://github.com/jeremieroy/bgfxGWEN/tree/master/premake
It is used like this in my premake.lua file:
dofile "bgfx_compile_shader.lua"
function compileShaders()
bgfx_compile_shader(INPUT_SHADERS_DIR, ENV_DIR, BUILD_DIR, "dx9" )
bgfx_compile_shader(INPUT_SHADERS_DIR, ENV_DIR, BUILD_DIR, "dx11" )
bgfx_compile_shader(INPUT_SHADERS_DIR, ENV_DIR, BUILD_DIR, "nacl" )
bgfx_compile_shader(INPUT_SHADERS_DIR, ENV_DIR, BUILD_DIR, "android" )
bgfx_compile_shader(INPUT_SHADERS_DIR, ENV_DIR, BUILD_DIR, "linux" )
end
However, I didn't get exactly what the dependencies are supposed to do. (files with .bin.d) (recursive call to make ?)
Didn't find a sample that use it in the bgfx repo. I'll update my premake file once I get it.
from bgfx.
bgfx shaders can include files, dependencies (it's standard makefile dependency functionality) are there to recognize changes and rebuild all affected shaders. For example if you include shaderlib.sh and use it in your shaders, once new functionality is added to shaderlib.sh all shaders that depend on it will be rebuilt.
from bgfx.
It make sense.
I'll look how to do it with premake.
Another minor issue (that doesn't necessary require a fix) I encountered:
Shader file compiled with shaderc must contains a final endline.
If it doesn't it refuse to compile with a :"error X3000: syntax error: unexpected end of file"
While I understand that this is part of the posix standard definition of a text file, (for good legit reasons) many text editors don't do it by default. (I'm using SublimeText2)
And when you encounter the issue, it's not obvious to understand what is wrong. (could be a bracket, a macro issue etc...)
I think this could be very easily handled in shaderc, (e.g. after loading the file, add a trailing newline if it is missing. Or throw an explicit error message. )
However, this is not a big deal ^^'
from bgfx.
I'm going to fix that. Thanks for reporting these issues, it will make it better for others who try it. :)
from bgfx.
You're welcome.
But you are the one to deserve the praise, your code is beautiful :)
Another (minor) issue: adding "void" in the main function of a shader return a random error.
(while this is legit glsl code)
void main(void)
{
float dist = texture2D(u_texColor, v_texcoord0.xy).a;
return a random error
void main()
{
float dist = texture2D(u_texColor, v_texcoord0.xy).a;
works fine.
from bgfx.
Thanks! :)
Yeah bgfx shader although it looks like GLSL should not be considered 100% GLSL, because it's HLSL code when compiling for DX9 and DX11. I just used preprocessor trickery to unify all those and have single shader source code.
"void main()" is "special" keyword... I'll add better error message if "void main()" doesn't exist.
from bgfx.
Fixed cc69b20
from bgfx.
Related Issues (20)
- xx-splat - 3D Gaussian Splatting for Real-Time Radiance Field Rendering HOT 11
- Vulkan fail to create swapchain on Wayland (Call to a X11 function ?) HOT 9
- Bug: DX3D12 crash in Debug mode HOT 7
- Small fix on soname defining on ldflags for Android examples. HOT 2
- Crash on linux (default backend - vulkan) with custom window handle and native display is NULL HOT 6
- Shaderc.cpp incorrectly adds PSSL preamble to compute shader HOT 1
- macOS version compatibility HOT 2
- Bad Vulkan performance due to weak index/vertex buffer management HOT 1
- Crash on resize: Nvidia RTX 4090 + Vulkan + Linux HOT 3
- Metal: example-01-helloworld corrupted render when MSAA is enabled HOT 2
- Shifted window buffer location when resizing a window HOT 1
- Vulkan Backend - incorrect mipmap generation for cubemap frame buffers. HOT 4
- Unable to build bgfx for iOS Simulator x86_64 arch HOT 4
- Vulkan on Android: the frame isn't updating (ONLY THE FIRST FRAME IS RENDERED) HOT 4
- Screenshot taken always from the main window backbuffer on MacOS/Metal
- Index buffer offset not being set with dynamic index buffer and indirect call HOT 25
- gl_NumWorkGroups doesn't compile when the target is DirectX HOT 1
- Feature request: Support FSR 3 instead of FSR 1
- Allow one executable to run with Vulkan on Wayland and X11 HOT 1
- BX and BGFX do not support the conformant MSVC preprocessor HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bgfx.