dragonjoker / ashes Goto Github PK
View Code? Open in Web Editor NEWDrop-in replacement for Vulkan shared library, for older hardware compatibility
Home Page: https://dragonjoker.github.io/Ashes/
License: MIT License
Drop-in replacement for Vulkan shared library, for older hardware compatibility
Home Page: https://dragonjoker.github.io/Ashes/
License: MIT License
With all these moves to improve compliance with vulkan.h, I will make Ashes a drop in replacement to Vulkan.
The first approach is an automatic one: you load Ashes shared library instead of Vulkan's, and you're done. The API selection will be done on first call of vkGetInstanceProcAddr
.
The second approach is a manual one: additionally, you can ask for the list of loaded plugins, through a call to the function int ashEnumeratePlugins( uint32_t * count , AshPluginDescription * plugins );
It works as Vulkan ones : if plugins
is set to NULL
, count
will then contain the number of loaded plugins.
AshPluginDescription
is defined as follows:
typedef struct AshPluginDescription
{
const char * name;
const char * description;
PFN_vkGetInstanceProcAddr getInstanceProcAddr;
} AshPluginDescription;
Some changes to this definition may be done, but the idea remains the same.
The struct and the function will be declared in ashes.h
I have been keeping an eye on your project, do you have a roadmap to where you are heading?
When a push constant is an array, GlRenderer bugs.
In base, no exceptions must be raised, at all.
This implies returning an error code, wherever it is needed.
A merge of these two ones into one single struct may be necessary.
on Arch linux
CMake Error at CMakeLists.txt:189 (add_subdirectory):
add_subdirectory given source "Templates" which is not an existing
directory.
CMake Error at CMakeLists.txt:193 (add_subdirectory):
add_subdirectory given source "Test" which is not an existing directory.
CMake Error at CMakeLists.txt:197 (add_subdirectory):
add_subdirectory given source "Samples" which is not an existing directory.
-- Configuring incomplete, errors occurred!
See also "/home/arthapz/Dev/repos/Ashes/build/CMakeFiles/CMakeOutput.log".
To make them more compilant with vulkan.h
Instead of having them in a global namespace, OpenGL functions should be members of the Device (or its context)
See #113
The OpenGL swapchain is limited, and this limit impacts the API structure (see SwapChain::createDepthStencil).
I must make it work like a Vulkan swapchain, hence I need to implement it as a FBO.
It will also allow to work with the swapchain images as with any other one.
It will help for #34
BC3, ASTC (check which ones) and ETC2.
This concept is completely alien to Direct3D 11.
Either you give your image its data at creation, or through texture copy/blit.
So, since in Vulkan you can't give an image its data at creation, I must copy from another texture.
Two cases:
What I'll do first, is the naive approach:
The only remaining question now is about the staging texture...
One more bit to #34
See #113
Problem here lies in OpenGL contexts....
It will need specific processing in OpenGL, to be able to generate the VAO when the draw commands are issued, and initialisation of this VAO must happen when the command buffer is submitted to a queue.
See #113
The various renderers use slightly different shader languages: SPIR-V, GLSL#150, GLSL#420, and HLSL (sm5).
Convertion to SPIR-V can be (and actually is) handled using glslang and libSPIRV.
For text shaders, I'd like to have a common language, that would be parsed inside each specific renderer.
I think a good starting point could be GLSL with Vulkan extensions (for push constants, which are handled as simple uniforms in OpenGL renderers, and as constant buffers in Direct3D11 renderer).
I would add some kind of annotation using #pragma
preprocessor directive, to help the renderers' parsers to make the appropriate replacements.
Let's start with the following annotated GLSL#420 vertex shader:
// Here, layout can remain as is, since it can be removed completely for GLSL#150,
// and replaced by a matching cbuffer in HLSL (except for 'set', which is another problem).
layout( set=0, binding=1 ) uniform Matrix
{
mat4 mtxProjection;
};
// The vertex shader inputs need a change, since D3D11 needs semantics
// (even if their names aren't important).
in VertexInput
{
#pragma semantic_name POSITION
#pragma semantic_index 0
layout( location = 0 ) vec4 position;
#pragma semantic_name TEXCOORD
#pragma semantic_index 0
layout( location = 1 ) vec2 texcoord;
};
// This one can be removed from D3D11 renderer's parser, and remain as is for others.
// It will also be used in D3D11 renderer's parser to define the SV_POSITION holder.
out gl_PerVertex
{
vec4 gl_Position;
};
// The vertex shader inputs need a change, since D3D11 needs semantics
// (even if their names aren't important).
out VertexOutput
{
#pragma semantic_name POSITION
#pragma semantic_index 0
layout( location = 0 ) vec3 vtx_position;
#pragma semantic_name TEXCOORD
#pragma semantic_index 0
layout( location = 1 ) vec2 vtx_texcoord;
}
// The main function will certainly need some rework inside the D3D parser,
// to be able to return what is needed, and to have what is need in entry.
void main()
{
// This specific line may be a problem (I'll explain later).
// Note that `ashesScalePosition` is the only Ashes intrinsic,
// which allows the renderer to transform the position
// to make it correct for it's own clip space.
gl_Position = mtxProjection * ashesScalePosition( position );
vtx_position = vec3( gl_Position );
vtx_texcoord = texcoord;
// In HLSL, we'll need a return statement.
}
The generated GLSL#150 would look like this (not a lot of changes, except for the layout specifier which is removed from the uniform buffer declaration):
uniform Matrix
{
mat4 mtxProjection;
};
in VertexInput
{
layout( location = 0 ) vec4 position;
layout( location = 1 ) vec2 texcoord;
};
out gl_PerVertex
{
vec4 gl_Position;
};
out VertexOutput
{
layout( location = 0 ) vec3 vtx_position;
layout( location = 1 ) vec2 vtx_texcoord;
};
void main()
{
gl_Position = mtxProjection * ashesScalePosition( position );
vtx_position = vec3( gl_Position );
vtx_texcoord = texcoord;
}
The generated HLSL would (obviously) be very different:
cbuffer Matrix: register(b1)
{
float4x4 mtxProjection;
};
struct VertexInput
{
float4 position: POSITION;
float2 texcoord: TEXCOORD;
};
struct VertexOutput
{
float4 gl_Position: SV_POSITION;
float3 vtx_position: POSITION;
float2 vtx_texcoord: TEXCOORD;
};
VertexOutput main( in VertexInput input )
{
VertexOutput output;
output.gl_Position = mul( mtxProjection, ashesScalePosition( input.position ) );
output.vtx_position = vec3( output.gl_Position );
output.vtx_texcoord = input.texcoord;
return output;
}
As far as I can see, this can be done without too much hard work.
Some points need attention though.
Matrix multiplication
In GLSL it is handled using multiplication operator *
, while in HLSL it is handled using the intrinsic function mul
.
I suggest using mul
in the common language, and the parsers would either provide the function, or replace it with multiplication operator (can be complex, since there can be anything, in the function call arguments).
Types
They'll need to be #define
d or completely replaced by the parser.
Intrinsics
Similar issue as types, they'll either need to be #define
d or completely replaced by the parser.
set
layout
This one is IMO a big issue, and it is unsolvable: in Vulkan we can specify the same binding, as long as the sets are different:
layout( set = 0, binding = 0 ) uniform Glop
{
//whatever
};
layout( set = 1, binding = 0 ) uniform Meow
{
//whatever else
};
This is perfectly valid with Vulkan, but impossible in other renderers.
It will probably be a limitation for users, when using Ashes.
I'm open to any suggestion that would help :).
The lib isn't tested at all on Android.
I don't have any Apple device, hence I can't do it by myself, feel free to start working on it :P
See #113
Create MemoryRequirements and DeviceMemory in RendererLib.
This will require the effective creation of an OpenGL image/buffer storage when the call is made to bindMemory.
See #113
See #113
And DescriptorSetPool should only be used to wrap this class.
This is the replacement for previous Ashes.
It will only call vanilla Vulkan functions.
See #113
Instead of enabling a context through Device::enable, implement automatic context enabling for the current thread.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.