Giter Club home page Giter Club logo

Comments (10)

jeremieroy avatar jeremieroy commented on May 22, 2024

(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.

bkaradzic avatar bkaradzic commented on May 22, 2024

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.

bkaradzic avatar bkaradzic commented on May 22, 2024

Fixed 391ebae

from bgfx.

jeremieroy avatar jeremieroy commented on May 22, 2024

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.

bkaradzic avatar bkaradzic commented on May 22, 2024

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.

jeremieroy avatar jeremieroy commented on May 22, 2024

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.

bkaradzic avatar bkaradzic commented on May 22, 2024

I'm going to fix that. Thanks for reporting these issues, it will make it better for others who try it. :)

from bgfx.

jeremieroy avatar jeremieroy commented on May 22, 2024

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.

bkaradzic avatar bkaradzic commented on May 22, 2024

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.

bkaradzic avatar bkaradzic commented on May 22, 2024

Fixed cc69b20

from bgfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.