Skip to content

GRAPHICS_API switch for Win32/Android/Linux#826

Merged
CedricGuillemet merged 71 commits into
BabylonJS:masterfrom
CedricGuillemet:vulkanBuild
Dec 13, 2021
Merged

GRAPHICS_API switch for Win32/Android/Linux#826
CedricGuillemet merged 71 commits into
BabylonJS:masterfrom
CedricGuillemet:vulkanBuild

Conversation

@CedricGuillemet

@CedricGuillemet CedricGuillemet commented Jul 9, 2021

Copy link
Copy Markdown
Collaborator

Select Graphics API this way:

cmake .. -G "Visual Studio 16 2019" -DGRAPHICS_API=D3D12

Need #950 to be merged before this one.

Vulkan status:
Current state: Playground runs and displays a green cube. Uniforms for VS are properly bound. For FS, it looks like uniforms are shuffled.
image

Cube appears green because vAmbientColor is full green. No idea why it happens.

image

@CedricGuillemet CedricGuillemet linked an issue Aug 3, 2021 that may be closed by this pull request
@CedricGuillemet

Copy link
Copy Markdown
Collaborator Author

@bghgary @darraghjburke Regarding D3D12/D3D11 shader compilation. I've put everything in 1 file and just added an #include per platform. Not great but does the job. Do you see anything better that can be done?

}

ShaderCompilerTraversers::IdGenerator ids{};
auto cutScope = ShaderCompilerTraversers::ChangeUniformTypes(program, ids);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uniform bloc is the same for the VS and FS. FS uniforms definition start with an offset in that buffer. For D3D12, this offset must be 16bytes aligned. So, with vec4/mat4, it is. D3D11 uniform definition is different but making it aligned anyway.

@CedricGuillemet

Copy link
Copy Markdown
Collaborator Author

gltf2 samples (models and generated) are passing with mandatory BABYLON.MorphTargetManager.EnableTextureStorage = false;

Comment on lines +9 to +11
// bgfx D3D12 implementation device refcount is not 0 when shutting down. This only happens when no HWND is provided.
// https://github.com/bkaradzic/bgfx/blob/60c64a3f77aca01fea715fa8ba7a2b1f0ca77f38/src/renderer_d3d12.cpp#L1470
// Until the fix is done in bgfx, create a window and associate the context with it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an issue filed for this?

target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_DEBUG_UNIFORM=0)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MULTITHREADED=1)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MAX_VERTEX_STREAMS=32)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MAX_VERTEX_STREAMS=16)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked offline and verified 16 is okay. Plus, we limit to 16 on the JS side right now anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vulkan port

3 participants