Context & Goal
Shader loading can be widely dependent on the user whether how they would like to handle fetching the shader byte code. The file I/O aspect is an implementation detail best left the responsible to the user.
This change involves removing internal code that automatically reads compiled SPIR-V binary files from disk:
|
compile_binary_shader_source(shader_src); |
Proposing New API Changes
To provide a better flexibility with reading the bytes of the compiled shader code. It would be best to just past through the raw bytes themselves.
To provide better flexibility and eliminate internal file handling, the new vulkan-cpp wrapper APIs should accept the raw bytecode directly.
Originally Design:
struct shader_source {
std::string filename;
shader_stage stage = shader_stage::undefined;
};
New Design:
struct shader_source {
shader_stage stage = shader_stage::undefined;
std::span<const uint8_t> bytes_code;
};
Expected for Task Completion
The implementation is quite straightforward. Rather then vk::shader_resource_group automatically loading the .spv file and parsing binary code internally, this responsibility shifts entirely to the user in how they implement that logic.
Expected API Usage Example
// reads and returns the bytes of the shader code compiled.
std::vector<uint8_t> compiled_bytes = read_compiled_spv("shader.vert.spv");
std::array<vk::shader_source, 1> sources = {
vk::shader_source{
.stage = vk::shader_stage::vertex,
.bytes_code = compiled_bytes,
},
};
vk::shader_resource_group shader_resources(logical_device, sources);
shader_resources.vertex_attributes(...);
Context & Goal
Shader loading can be widely dependent on the user whether how they would like to handle fetching the shader byte code. The file I/O aspect is an implementation detail best left the responsible to the user.
This change involves removing internal code that automatically reads compiled SPIR-V binary files from disk:
vulkan-cpp/vulkan-cpp/shader_resource.cppm
Line 53 in 36fab78
Proposing New API Changes
To provide a better flexibility with reading the bytes of the compiled shader code. It would be best to just past through the raw bytes themselves.
To provide better flexibility and eliminate internal file handling, the new vulkan-cpp wrapper APIs should accept the raw bytecode directly.
Originally Design:
New Design:
Expected for Task Completion
The implementation is quite straightforward. Rather then
vk::shader_resource_groupautomatically loading the.spvfile and parsing binary code internally, this responsibility shifts entirely to the user in how they implement that logic.Expected API Usage Example