Compare commits
3 Commits
a10ed8bc60
...
2e018962ee
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e018962ee | |||
| c62240641a | |||
| 5f5bc08068 |
@ -8,9 +8,9 @@
|
|||||||
"useLightmaps": false,
|
"useLightmaps": false,
|
||||||
"max": 32,
|
"max": 32,
|
||||||
"shadows": {
|
"shadows": {
|
||||||
"enabled": false, // to-do: fix
|
"enabled": true, // to-do: fix
|
||||||
"update": 4,
|
"update": 4,
|
||||||
"max": 8,
|
"max": 16,
|
||||||
"samples": 2
|
"samples": 2
|
||||||
},
|
},
|
||||||
"bloom": {
|
"bloom": {
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
"bias": {
|
"bias": {
|
||||||
"constant": 1.25,
|
"constant": 1.25,
|
||||||
"slope": 1.75,
|
"slope": 1.75,
|
||||||
"shader": 0.000005 // 0.000005 //0.000000005
|
"shader": 0.00005 // 0.000005 //0.000000005
|
||||||
},
|
},
|
||||||
"radius": [0.5, 0],
|
"radius": [0.5, 0],
|
||||||
"resolution": 1024,
|
"resolution": 1024,
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"type": "Object",
|
"type": "Object",
|
||||||
"name": "Player: Model",
|
"name": "Player: Model",
|
||||||
"ignore": true,
|
"ignore": false,
|
||||||
"import": "/model.json",
|
"import": "/model.json",
|
||||||
"assets": [
|
"assets": [
|
||||||
"/player/ben.glb"
|
// "/player/ben.glb"
|
||||||
// { "filename": "/player/bear/graph.json" }
|
{ "filename": "/player/bear/graph.json" }
|
||||||
],
|
],
|
||||||
"behaviors": [
|
"behaviors": [
|
||||||
"PlayerModelBehavior"
|
"PlayerModelBehavior"
|
||||||
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"track": true,
|
"track": true,
|
||||||
"hide": false,
|
"hide": true,
|
||||||
"graph": {
|
"graph": {
|
||||||
"debug": {
|
"debug": {
|
||||||
"print": {
|
"print": {
|
||||||
|
|||||||
@ -102,6 +102,8 @@ int main(int argc, char** argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ( client::ready && uf::ready ) {
|
while ( client::ready && uf::ready ) {
|
||||||
|
++uf::time::frame;
|
||||||
|
|
||||||
#if UF_EXCEPTIONS
|
#if UF_EXCEPTIONS
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -29,6 +29,30 @@ namespace ext {
|
|||||||
operator VkCommandBuffer() { return handle; }
|
operator VkCommandBuffer() { return handle; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DescriptorAllocator {
|
||||||
|
VkDevice device = VK_NULL_HANDLE;
|
||||||
|
VkDescriptorPool currentPool = VK_NULL_HANDLE;
|
||||||
|
uf::stl::vector<VkDescriptorPool> usedPools;
|
||||||
|
|
||||||
|
uf::stl::vector<VkDescriptorPoolSize> poolSizes = {
|
||||||
|
{ VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 4000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 4000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 2000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 2000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 500 },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 100 }
|
||||||
|
};
|
||||||
|
|
||||||
|
void initialize( VkDevice );
|
||||||
|
void destroy();
|
||||||
|
VkDescriptorPool createPool();
|
||||||
|
bool allocate( VkDescriptorSet* set, VkDescriptorSetLayout layout );
|
||||||
|
};
|
||||||
|
|
||||||
struct Texture;
|
struct Texture;
|
||||||
|
|
||||||
struct UF_API Device {
|
struct UF_API Device {
|
||||||
@ -69,6 +93,7 @@ namespace ext {
|
|||||||
} extensions;
|
} extensions;
|
||||||
|
|
||||||
VkPipelineCache pipelineCache;
|
VkPipelineCache pipelineCache;
|
||||||
|
DescriptorAllocator descriptorAllocator;
|
||||||
|
|
||||||
uf::stl::vector<VkQueueFamilyProperties> queueFamilyProperties;
|
uf::stl::vector<VkQueueFamilyProperties> queueFamilyProperties;
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,8 @@ namespace ext {
|
|||||||
struct Graphic;
|
struct Graphic;
|
||||||
|
|
||||||
struct UF_API Pipeline : public Buffers {
|
struct UF_API Pipeline : public Buffers {
|
||||||
|
static uf::stl::unordered_map<GraphicDescriptor, Pipeline> pipelines;
|
||||||
|
|
||||||
bool aliased = false;
|
bool aliased = false;
|
||||||
|
|
||||||
Device* device = NULL;
|
Device* device = NULL;
|
||||||
@ -19,19 +21,27 @@ namespace ext {
|
|||||||
VkPipeline pipeline = VK_NULL_HANDLE;
|
VkPipeline pipeline = VK_NULL_HANDLE;
|
||||||
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
|
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
|
||||||
VkDescriptorSetLayout descriptorSetLayout = VK_NULL_HANDLE;
|
VkDescriptorSetLayout descriptorSetLayout = VK_NULL_HANDLE;
|
||||||
VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
|
|
||||||
VkDescriptorSet descriptorSet = VK_NULL_HANDLE;
|
|
||||||
GraphicDescriptor descriptor = {};
|
GraphicDescriptor descriptor = {};
|
||||||
|
|
||||||
uf::stl::vector<VkStridedDeviceAddressRegionKHR> sbtEntries;
|
uf::stl::vector<VkStridedDeviceAddressRegionKHR> sbtEntries;
|
||||||
|
|
||||||
struct {
|
void initialize( const Graphic& graphic );
|
||||||
uf::Serializer json;
|
void initialize( const Graphic& graphic, const GraphicDescriptor& descriptor );
|
||||||
|
void record( const Graphic& graphic, VkCommandBuffer, size_t = 0, size_t = 0, size_t = 0 ) const;
|
||||||
|
void destroy();
|
||||||
|
};
|
||||||
|
|
||||||
uf::stl::string type = "";
|
struct UF_API DescriptorSet : public Buffers {
|
||||||
bool process = true;
|
bool aliased = false;
|
||||||
bool rebuild = false;
|
|
||||||
|
Device* device = NULL;
|
||||||
|
|
||||||
|
VkDescriptorSet descriptorSet = {};
|
||||||
|
GraphicDescriptor descriptor = {};
|
||||||
|
|
||||||
|
struct {
|
||||||
bool built = false;
|
bool built = false;
|
||||||
|
bool process = true;
|
||||||
} metadata;
|
} metadata;
|
||||||
|
|
||||||
void initialize( const Graphic& graphic );
|
void initialize( const Graphic& graphic );
|
||||||
@ -42,9 +52,6 @@ namespace ext {
|
|||||||
void record( const Graphic& graphic, const GraphicDescriptor& descriptor, VkCommandBuffer, size_t = 0, size_t = 0, size_t = 0 ) const;
|
void record( const Graphic& graphic, const GraphicDescriptor& descriptor, VkCommandBuffer, size_t = 0, size_t = 0, size_t = 0 ) const;
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
uf::stl::vector<Shader*> getShaders( uf::stl::vector<Shader>&, const uf::stl::string& = "" );
|
|
||||||
uf::stl::vector<const Shader*> getShaders( const uf::stl::vector<Shader>&, const uf::stl::string& = "" ) const;
|
|
||||||
|
|
||||||
void collectBuffers( const Shader& shader, const RenderMode& renderMode, const Graphic& graphic, const std::function<void(const Buffer&)>& lambda ) const;
|
void collectBuffers( const Shader& shader, const RenderMode& renderMode, const Graphic& graphic, const std::function<void(const Buffer&)>& lambda ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,6 +68,7 @@ namespace ext {
|
|||||||
bool autoInitializeUniformBuffers = true;
|
bool autoInitializeUniformBuffers = true;
|
||||||
bool autoInitializeUniformUserdatas = false;
|
bool autoInitializeUniformUserdatas = false;
|
||||||
uf::stl::unordered_map<uf::stl::string, size_t> shaders;
|
uf::stl::unordered_map<uf::stl::string, size_t> shaders;
|
||||||
|
uf::stl::unordered_map<uf::stl::string, size_t> hashes;
|
||||||
} metadata;
|
} metadata;
|
||||||
|
|
||||||
void initialize( Device& device );
|
void initialize( Device& device );
|
||||||
@ -73,6 +81,8 @@ namespace ext {
|
|||||||
Shader& getShader( const uf::stl::string& type, const uf::stl::string& pipeline = "" );
|
Shader& getShader( const uf::stl::string& type, const uf::stl::string& pipeline = "" );
|
||||||
const Shader& getShader( const uf::stl::string& type, const uf::stl::string& pipeline = "" ) const;
|
const Shader& getShader( const uf::stl::string& type, const uf::stl::string& pipeline = "" ) const;
|
||||||
|
|
||||||
|
uf::stl::vector<const Shader*> getShaders( const uf::stl::string& = "" ) const;
|
||||||
|
|
||||||
bool validate();
|
bool validate();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,7 +92,9 @@ namespace ext {
|
|||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
bool process = true;
|
bool process = true;
|
||||||
Material material = {};
|
Material material = {};
|
||||||
|
|
||||||
uf::stl::unordered_map<GraphicDescriptor, Pipeline> pipelines;
|
uf::stl::unordered_map<GraphicDescriptor, Pipeline> pipelines;
|
||||||
|
uf::stl::unordered_map<GraphicDescriptor, DescriptorSet> descriptorSets;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uf::stl::unordered_map<uf::stl::string, size_t> buffers;
|
uf::stl::unordered_map<uf::stl::string, size_t> buffers;
|
||||||
@ -95,6 +107,9 @@ namespace ext {
|
|||||||
|
|
||||||
~Graphic();
|
~Graphic();
|
||||||
void initialize( const uf::stl::string& = "" );
|
void initialize( const uf::stl::string& = "" );
|
||||||
|
void initialize( const GraphicDescriptor& );
|
||||||
|
void update();
|
||||||
|
void update( const GraphicDescriptor& );
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
// raster
|
// raster
|
||||||
@ -104,17 +119,22 @@ namespace ext {
|
|||||||
void generateBottomAccelerationStructures();
|
void generateBottomAccelerationStructures();
|
||||||
void generateTopAccelerationStructure( const uf::stl::vector<uf::renderer::Graphic*>&, const uf::stl::vector<pod::Instance>&, const uf::stl::vector<pod::Matrix4f>& );
|
void generateTopAccelerationStructure( const uf::stl::vector<uf::renderer::Graphic*>&, const uf::stl::vector<pod::Instance>&, const uf::stl::vector<pod::Matrix4f>& );
|
||||||
|
|
||||||
bool hasPipeline( const GraphicDescriptor& descriptor ) const;
|
|
||||||
void initializePipeline();
|
void initializePipeline();
|
||||||
Pipeline& initializePipeline( const GraphicDescriptor& descriptor, bool update = true );
|
Pipeline& initializePipeline( const GraphicDescriptor& descriptor );
|
||||||
|
|
||||||
|
bool hasPipeline( const GraphicDescriptor& descriptor ) const;
|
||||||
Pipeline& getPipeline();
|
Pipeline& getPipeline();
|
||||||
const Pipeline& getPipeline() const;
|
const Pipeline& getPipeline() const;
|
||||||
|
|
||||||
Pipeline& getPipeline( const GraphicDescriptor& descriptor );
|
Pipeline& getPipeline( const GraphicDescriptor& descriptor );
|
||||||
const Pipeline& getPipeline( const GraphicDescriptor& descriptor ) const;
|
const Pipeline& getPipeline( const GraphicDescriptor& descriptor ) const;
|
||||||
|
|
||||||
void updatePipelines();
|
void initializeDescriptorSet();
|
||||||
|
DescriptorSet& initializeDescriptorSet( const GraphicDescriptor& descriptor );
|
||||||
|
bool hasDescriptorSet( const GraphicDescriptor& descriptor ) const;
|
||||||
|
DescriptorSet& getDescriptorSet();
|
||||||
|
const DescriptorSet& getDescriptorSet() const;
|
||||||
|
DescriptorSet& getDescriptorSet( const GraphicDescriptor& descriptor );
|
||||||
|
const DescriptorSet& getDescriptorSet( const GraphicDescriptor& descriptor ) const;
|
||||||
|
|
||||||
void record( VkCommandBuffer commandBuffer, size_t pass = 0, size_t draw = 0, size_t offset = 0 ) const;
|
void record( VkCommandBuffer commandBuffer, size_t pass = 0, size_t draw = 0, size_t offset = 0 ) const;
|
||||||
void record( VkCommandBuffer commandBuffer, const GraphicDescriptor& descriptor, size_t pass = 0, size_t draw = 0, size_t offset = 0 ) const;
|
void record( VkCommandBuffer commandBuffer, const GraphicDescriptor& descriptor, size_t pass = 0, size_t draw = 0, size_t offset = 0 ) const;
|
||||||
|
|||||||
@ -430,6 +430,7 @@ namespace ext {
|
|||||||
|
|
||||||
uf::stl::string renderMode = "";
|
uf::stl::string renderMode = "";
|
||||||
uf::stl::string pipeline = "";
|
uf::stl::string pipeline = "";
|
||||||
|
hash_t material = {};
|
||||||
|
|
||||||
uint32_t renderTarget = 0;
|
uint32_t renderTarget = 0;
|
||||||
uint32_t subpass = 0;
|
uint32_t subpass = 0;
|
||||||
|
|||||||
@ -733,7 +733,7 @@ void UF_API uf::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UF_API uf::tick() {
|
void UF_API uf::tick() {
|
||||||
++uf::time::frame;
|
//++uf::time::frame;
|
||||||
|
|
||||||
static pod::Thread& threadMain = uf::thread::get(uf::thread::mainThreadName);
|
static pod::Thread& threadMain = uf::thread::get(uf::thread::mainThreadName);
|
||||||
#if UF_THREAD_METRICS
|
#if UF_THREAD_METRICS
|
||||||
|
|||||||
@ -201,8 +201,6 @@ void ext::GuiBehavior::initialize( uf::Object& self ) {
|
|||||||
{filenames.vertex, uf::renderer::enums::Shader::VERTEX},
|
{filenames.vertex, uf::renderer::enums::Shader::VERTEX},
|
||||||
{filenames.fragment, uf::renderer::enums::Shader::FRAGMENT},
|
{filenames.fragment, uf::renderer::enums::Shader::FRAGMENT},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
#if UF_USE_VULKAN
|
#if UF_USE_VULKAN
|
||||||
{
|
{
|
||||||
auto& shader = graphic.material.getShader("vertex");
|
auto& shader = graphic.material.getShader("vertex");
|
||||||
@ -215,7 +213,7 @@ void ext::GuiBehavior::initialize( uf::Object& self ) {
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
graphic.initializeMesh( mesh );
|
graphic.initializeMesh( mesh );
|
||||||
graphic.getPipeline().update( graphic );
|
graphic.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( payload.free ) {
|
if ( payload.free ) {
|
||||||
|
|||||||
@ -75,7 +75,7 @@ void ext::PlayerBehavior::initialize( uf::Object& self ) {
|
|||||||
}
|
}
|
||||||
camera.setProjection( uf::matrix::perspective( fov, raidou, range.x, range.y ) );
|
camera.setProjection( uf::matrix::perspective( fov, raidou, range.x, range.y ) );
|
||||||
}
|
}
|
||||||
// camera.update(true);
|
camera.update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sloppy
|
// sloppy
|
||||||
@ -668,7 +668,7 @@ void ext::PlayerBehavior::tick( uf::Object& self ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// camera.update(true);
|
camera.update(true);
|
||||||
|
|
||||||
#if UF_ENTITY_METADATA_USE_JSON
|
#if UF_ENTITY_METADATA_USE_JSON
|
||||||
metadata.serialize(self, metadataJson);
|
metadata.serialize(self, metadataJson);
|
||||||
|
|||||||
@ -51,12 +51,12 @@ void ext::PlayerModelBehavior::tick( uf::Object& self ) {
|
|||||||
this->process([&](uf::Entity* entity){
|
this->process([&](uf::Entity* entity){
|
||||||
if ( !entity->hasComponent<uf::Graphic>() ) return;
|
if ( !entity->hasComponent<uf::Graphic>() ) return;
|
||||||
auto& graphic = entity->getComponent<uf::Graphic>();
|
auto& graphic = entity->getComponent<uf::Graphic>();
|
||||||
auto& pipeline = graphic.getPipeline();
|
if ( !graphic.initialized ) return;
|
||||||
pipeline.metadata.process = !metadata.hide;
|
auto& descriptorSet = graphic.getDescriptorSet();
|
||||||
metadata.set = true;
|
descriptorSet.metadata.process = !metadata.hide;
|
||||||
});
|
|
||||||
metadata.set = true;
|
metadata.set = true;
|
||||||
uf::renderer::states::rebuild = true;
|
uf::renderer::states::rebuild = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ext::PlayerModelBehavior::render( uf::Object& self ){}
|
void ext::PlayerModelBehavior::render( uf::Object& self ){}
|
||||||
|
|||||||
@ -235,7 +235,7 @@ void ext::RayTraceSceneBehavior::tick( uf::Object& self ) {
|
|||||||
}
|
}
|
||||||
if ( metadata.renderer.full ) {
|
if ( metadata.renderer.full ) {
|
||||||
/* Update lights */ {
|
/* Update lights */ {
|
||||||
ext::ExtSceneBehavior::bindBuffers( *this, graphic, "ray:gen", uf::renderer::settings::pipelines::names::rt );
|
ext::ExtSceneBehavior::bindBuffers( *this, graphic, "", "ray:gen", uf::renderer::settings::pipelines::names::rt );
|
||||||
}
|
}
|
||||||
if ( !metadata.renderer.bound ) return;
|
if ( !metadata.renderer.bound ) return;
|
||||||
#if !UF_USE_EXTERNAL_IMAGE
|
#if !UF_USE_EXTERNAL_IMAGE
|
||||||
@ -245,7 +245,7 @@ void ext::RayTraceSceneBehavior::tick( uf::Object& self ) {
|
|||||||
graphic.descriptor.bind.height = renderMode.height > 0 ? renderMode.height : uf::renderer::settings::height;
|
graphic.descriptor.bind.height = renderMode.height > 0 ? renderMode.height : uf::renderer::settings::height;
|
||||||
graphic.descriptor.bind.point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR;
|
graphic.descriptor.bind.point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR;
|
||||||
graphic.descriptor.pipeline = uf::renderer::settings::pipelines::names::rt;
|
graphic.descriptor.pipeline = uf::renderer::settings::pipelines::names::rt;
|
||||||
graphic.getPipeline().update( graphic );
|
graphic.update();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
@ -288,7 +288,7 @@ void ext::RayTraceSceneBehavior::tick( uf::Object& self ) {
|
|||||||
graphic.descriptor.bind.height = image.height;
|
graphic.descriptor.bind.height = image.height;
|
||||||
graphic.descriptor.bind.point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR;
|
graphic.descriptor.bind.point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR;
|
||||||
|
|
||||||
graphic.getPipeline().update( graphic );
|
graphic.update();
|
||||||
|
|
||||||
if ( blitter.material.hasShader("fragment") ) {
|
if ( blitter.material.hasShader("fragment") ) {
|
||||||
auto& shader = blitter.material.getShader("fragment");
|
auto& shader = blitter.material.getShader("fragment");
|
||||||
|
|||||||
@ -458,7 +458,7 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) {
|
|||||||
auto/*&*/ graph = this->getGraph();
|
auto/*&*/ graph = this->getGraph();
|
||||||
auto& controller = this->getController();
|
auto& controller = this->getController();
|
||||||
// auto& camera = controller.getComponent<uf::Camera>();
|
// auto& camera = controller.getComponent<uf::Camera>();
|
||||||
auto& camera = this->getCamera( controller );
|
// auto& camera = this->getCamera( controller );
|
||||||
auto& controllerMetadata = controller.getComponent<uf::Serializer>();
|
auto& controllerMetadata = controller.getComponent<uf::Serializer>();
|
||||||
auto& controllerTransform = controller.getComponent<pod::Transform<>>();
|
auto& controllerTransform = controller.getComponent<pod::Transform<>>();
|
||||||
auto& metadata = this->getComponent<ext::ExtSceneBehavior::Metadata>();
|
auto& metadata = this->getComponent<ext::ExtSceneBehavior::Metadata>();
|
||||||
@ -524,8 +524,6 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) {
|
|||||||
auto& storage = uf::graph::globalStorage ? uf::graph::storage : this->getComponent<pod::Graph::Storage>();
|
auto& storage = uf::graph::globalStorage ? uf::graph::storage : this->getComponent<pod::Graph::Storage>();
|
||||||
auto/*&*/ graph = this->getGraph();
|
auto/*&*/ graph = this->getGraph();
|
||||||
auto& controller = this->getController();
|
auto& controller = this->getController();
|
||||||
// auto& camera = controller.getComponent<uf::Camera>();
|
|
||||||
auto& camera = this->getCamera( controller );
|
|
||||||
auto& controllerMetadata = controller.getComponent<uf::Serializer>();
|
auto& controllerMetadata = controller.getComponent<uf::Serializer>();
|
||||||
auto& controllerTransform = controller.getComponent<pod::Transform<>>();
|
auto& controllerTransform = controller.getComponent<pod::Transform<>>();
|
||||||
auto& metadata = this->getComponent<ext::ExtSceneBehavior::Metadata>();
|
auto& metadata = this->getComponent<ext::ExtSceneBehavior::Metadata>();
|
||||||
@ -919,9 +917,13 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali
|
|||||||
|
|
||||||
void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, const uf::stl::string& renderModeName, const uf::stl::string& shaderType, const uf::stl::string& shaderPipeline ) {
|
void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, const uf::stl::string& renderModeName, const uf::stl::string& shaderType, const uf::stl::string& shaderPipeline ) {
|
||||||
auto& renderMode = uf::renderer::getRenderMode(renderModeName, true);
|
auto& renderMode = uf::renderer::getRenderMode(renderModeName, true);
|
||||||
bindBuffers( self, renderMode.getBlitter(), shaderType, shaderPipeline );
|
bindBuffers( self, renderMode.getBlitter(), renderMode, shaderType, shaderPipeline );
|
||||||
}
|
}
|
||||||
void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic& graphic, const uf::stl::string& shaderType, const uf::stl::string& shaderPipeline ) {
|
void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic& graphic, const uf::stl::string& renderModeName, const uf::stl::string& shaderType, const uf::stl::string& shaderPipeline ) {
|
||||||
|
auto& renderMode = uf::renderer::getRenderMode(renderModeName, true);
|
||||||
|
bindBuffers( self, graphic, renderMode, shaderType, shaderPipeline );
|
||||||
|
}
|
||||||
|
void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic& graphic, uf::renderer::RenderMode& renderMode, const uf::stl::string& shaderType, const uf::stl::string& shaderPipeline ) {
|
||||||
auto/*&*/ graph = this->getGraph();
|
auto/*&*/ graph = this->getGraph();
|
||||||
auto& controller = this->getController();
|
auto& controller = this->getController();
|
||||||
// auto& camera = controller.getComponent<uf::Camera>();
|
// auto& camera = controller.getComponent<uf::Camera>();
|
||||||
@ -1245,7 +1247,9 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
|
|||||||
if ( previousTextures[i] != graphic.material.textures[i].image ) shouldUpdate = true;
|
if ( previousTextures[i] != graphic.material.textures[i].image ) shouldUpdate = true;
|
||||||
}
|
}
|
||||||
if ( shouldUpdate ) {
|
if ( shouldUpdate ) {
|
||||||
graphic.updatePipelines();
|
// graphic.updatePipelines();
|
||||||
|
graphic.update();
|
||||||
|
renderMode.rebuild = true;
|
||||||
metadata.shader.invalidated = false;
|
metadata.shader.invalidated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,9 @@ namespace ext {
|
|||||||
} framebuffer;
|
} framebuffer;
|
||||||
);
|
);
|
||||||
|
|
||||||
void bindBuffers( uf::Object&, const uf::stl::string& = "", const uf::stl::string& = "fragment", const uf::stl::string& = "deferred" );
|
void bindBuffers( uf::Object&, const uf::stl::string&, const uf::stl::string&, const uf::stl::string& );
|
||||||
void bindBuffers( uf::Object&, uf::renderer::Graphic&, const uf::stl::string& = "fragment", const uf::stl::string& = "deferred" );
|
void bindBuffers( uf::Object&, uf::renderer::Graphic&, const uf::stl::string&, const uf::stl::string&, const uf::stl::string& );
|
||||||
|
|
||||||
|
void bindBuffers( uf::Object&, uf::renderer::Graphic&, uf::renderer::RenderMode&, const uf::stl::string& = "compute", const uf::stl::string& = "deferred" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,7 +236,9 @@ void ext::VoxelizerSceneBehavior::initialize( uf::Object& self ) {
|
|||||||
//descriptor.pipeline = "lighting";
|
//descriptor.pipeline = "lighting";
|
||||||
|
|
||||||
auto& pipeline = blitter.getPipeline( descriptor );
|
auto& pipeline = blitter.getPipeline( descriptor );
|
||||||
|
auto& descriptorSet = blitter.getDescriptorSet( descriptor );
|
||||||
pipeline.record( blitter, commandBuffer );
|
pipeline.record( blitter, commandBuffer );
|
||||||
|
descriptorSet.record( blitter, commandBuffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate mipmaps
|
// generate mipmaps
|
||||||
@ -264,7 +266,9 @@ void ext::VoxelizerSceneBehavior::initialize( uf::Object& self ) {
|
|||||||
descriptor.pipeline = "mipmap";
|
descriptor.pipeline = "mipmap";
|
||||||
|
|
||||||
auto& pipeline = blitter.getPipeline( descriptor );
|
auto& pipeline = blitter.getPipeline( descriptor );
|
||||||
|
auto& descriptorSet = blitter.getDescriptorSet( descriptor );
|
||||||
pipeline.record( blitter, commandBuffer );
|
pipeline.record( blitter, commandBuffer );
|
||||||
|
descriptorSet.record( blitter, commandBuffer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -25,7 +25,10 @@ namespace {
|
|||||||
|
|
||||||
auto& animation = storage.animations.map[name];
|
auto& animation = storage.animations.map[name];
|
||||||
|
|
||||||
UF_ASSERT( animation.path != "" );
|
//UF_ASSERT( animation.path != "" );
|
||||||
|
if ( animation.path == "" ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uf::Serializer json;
|
uf::Serializer json;
|
||||||
json.readFromFile( animation.path );
|
json.readFromFile( animation.path );
|
||||||
|
|||||||
@ -1511,8 +1511,6 @@ void uf::graph::render( pod::Graph::Storage& storage ) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if ( controller.getName() == "Player" ) UF_MSG_DEBUG("frame={}, camera={}, renderMode={}, {}", uf::time::frame, uf::matrix::toString( viewport.matrices[0].view ), renderMode->getName(), renderMode->getType() );
|
|
||||||
|
|
||||||
storage.buffers.camera.update( (const void*) &viewport, sizeof(pod::Camera::Viewports) );
|
storage.buffers.camera.update( (const void*) &viewport, sizeof(pod::Camera::Viewports) );
|
||||||
|
|
||||||
#if UF_USE_VULKAN
|
#if UF_USE_VULKAN
|
||||||
|
|||||||
@ -75,18 +75,21 @@ uf::Camera& uf::Scene::getCamera(uf::Entity& controller) {
|
|||||||
auto& metadata = this->getComponent<uf::SceneBehavior::Metadata>();
|
auto& metadata = this->getComponent<uf::SceneBehavior::Metadata>();
|
||||||
#endif
|
#endif
|
||||||
auto uid = controller.getUid();
|
auto uid = controller.getUid();
|
||||||
auto& cachedCamera = metadata.cache.cameras[uid].camera;
|
auto& cache = metadata.cache.cameras[uid];
|
||||||
auto& lastFrame = metadata.cache.cameras[uid].lastFrame;
|
auto& cachedCamera = cache.camera;
|
||||||
|
auto& lastFrame = cache.lastFrame;
|
||||||
|
|
||||||
if ( lastFrame != uf::time::frame ) {
|
if ( lastFrame != uf::time::frame ) {
|
||||||
auto& sourceCamera = controller.getComponent<uf::Camera>();
|
auto& sourceCamera = controller.getComponent<uf::Camera>();
|
||||||
cachedCamera.setTransform(uf::transform::flatten(sourceCamera.getTransform()));
|
// update if camera wasn't already updated
|
||||||
|
//sourceCamera.update(true);
|
||||||
|
// copy all matrices
|
||||||
for ( auto i = 0; i < uf::camera::maxViews; ++i ) {
|
for ( auto i = 0; i < uf::camera::maxViews; ++i ) {
|
||||||
cachedCamera.setView(sourceCamera.getView(i), i);
|
cachedCamera.setView(sourceCamera.getView(i), i);
|
||||||
cachedCamera.setProjection(sourceCamera.getProjection(i), i);
|
cachedCamera.setProjection(sourceCamera.getProjection(i), i);
|
||||||
}
|
}
|
||||||
cachedCamera.update(true);
|
// flatten the transform in the event the parent transform updates later
|
||||||
|
cachedCamera.setTransform(uf::transform::flatten(cachedCamera.getTransform()));
|
||||||
lastFrame = uf::time::frame;
|
lastFrame = uf::time::frame;
|
||||||
}
|
}
|
||||||
return cachedCamera;
|
return cachedCamera;
|
||||||
@ -104,8 +107,9 @@ void uf::Scene::invalidateGraph() {
|
|||||||
auto& metadata = this->getComponent<uf::SceneBehavior::Metadata>();
|
auto& metadata = this->getComponent<uf::SceneBehavior::Metadata>();
|
||||||
#endif
|
#endif
|
||||||
metadata.invalidationQueued = true;
|
metadata.invalidationQueued = true;
|
||||||
/*
|
|
||||||
metadata.cache.controllers.clear();
|
metadata.cache.controllers.clear();
|
||||||
|
metadata.cache.cameras.clear();
|
||||||
|
/*
|
||||||
metadata.tasks.serial.clear();
|
metadata.tasks.serial.clear();
|
||||||
metadata.tasks.parallel.clear();
|
metadata.tasks.parallel.clear();
|
||||||
|
|
||||||
|
|||||||
@ -663,11 +663,7 @@ void ext::fsr::initialize() {
|
|||||||
blitter.descriptor.bind.height = uf::renderer::settings::height;
|
blitter.descriptor.bind.height = uf::renderer::settings::height;
|
||||||
blitter.descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
blitter.descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
|
|
||||||
if ( !blitter.hasPipeline( blitter.descriptor ) ) {
|
blitter.update( blitter.descriptor );
|
||||||
blitter.initializePipeline( blitter.descriptor );
|
|
||||||
} else if ( blitter.hasPipeline( blitter.descriptor ) ){
|
|
||||||
blitter.getPipeline( blitter.descriptor ).update( blitter, blitter.descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ext::fsr::initialized = true;
|
ext::fsr::initialized = true;
|
||||||
@ -763,11 +759,7 @@ void ext::fsr::tick() {
|
|||||||
blitter.descriptor.bind.width = displaySize.x;
|
blitter.descriptor.bind.width = displaySize.x;
|
||||||
blitter.descriptor.bind.height = displaySize.y;
|
blitter.descriptor.bind.height = displaySize.y;
|
||||||
|
|
||||||
if ( !blitter.hasPipeline( blitter.descriptor ) ) {
|
blitter.update( blitter.descriptor );
|
||||||
blitter.initializePipeline( blitter.descriptor );
|
|
||||||
} else if ( blitter.hasPipeline( blitter.descriptor ) ){
|
|
||||||
blitter.getPipeline( blitter.descriptor ).update( blitter, blitter.descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <uf/ext/vulkan/vulkan.h>
|
#include <uf/ext/vulkan/vulkan.h>
|
||||||
#include <uf/ext/vulkan/device.h>
|
#include <uf/ext/vulkan/device.h>
|
||||||
|
#include <uf/ext/vulkan/graphic.h>
|
||||||
#include <uf/ext/vulkan/initializers.h>
|
#include <uf/ext/vulkan/initializers.h>
|
||||||
#include <uf/utils/window/window.h>
|
#include <uf/utils/window/window.h>
|
||||||
#include <uf/utils/string/ext.h>
|
#include <uf/utils/string/ext.h>
|
||||||
@ -1507,6 +1508,10 @@ void ext::vulkan::Device::initialize() {
|
|||||||
VK_REGISTER_HANDLE( allocator );
|
VK_REGISTER_HANDLE( allocator );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
descriptorAllocator.initialize( logicalDevice );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
vkGetBufferDeviceAddressKHR = reinterpret_cast<PFN_vkGetBufferDeviceAddressKHR>(vkGetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR"));
|
vkGetBufferDeviceAddressKHR = reinterpret_cast<PFN_vkGetBufferDeviceAddressKHR>(vkGetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR"));
|
||||||
vkCmdBuildAccelerationStructuresKHR = reinterpret_cast<PFN_vkCmdBuildAccelerationStructuresKHR>(vkGetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR"));
|
vkCmdBuildAccelerationStructuresKHR = reinterpret_cast<PFN_vkCmdBuildAccelerationStructuresKHR>(vkGetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR"));
|
||||||
@ -1569,6 +1574,12 @@ void ext::vulkan::Device::destroy() {
|
|||||||
VK_UNREGISTER_HANDLE( this->pipelineCache );
|
VK_UNREGISTER_HANDLE( this->pipelineCache );
|
||||||
this->pipelineCache = nullptr;
|
this->pipelineCache = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( auto& pair : Pipeline::pipelines ) pair.second.destroy();
|
||||||
|
Pipeline::pipelines.clear();
|
||||||
|
|
||||||
|
descriptorAllocator.destroy();
|
||||||
|
|
||||||
for ( auto& pair : this->commandPool.graphics.container() ) {
|
for ( auto& pair : this->commandPool.graphics.container() ) {
|
||||||
vkDestroyCommandPool( this->logicalDevice, pair.second, nullptr );
|
vkDestroyCommandPool( this->logicalDevice, pair.second, nullptr );
|
||||||
VK_UNREGISTER_HANDLE( pair.second );
|
VK_UNREGISTER_HANDLE( pair.second );
|
||||||
@ -1608,4 +1619,50 @@ void ext::vulkan::Device::destroy() {
|
|||||||
VK_UNREGISTER_HANDLE( allocator );
|
VK_UNREGISTER_HANDLE( allocator );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ext::vulkan::DescriptorAllocator::initialize(VkDevice inDevice) {
|
||||||
|
device = inDevice;
|
||||||
|
currentPool = createPool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ext::vulkan::DescriptorAllocator::destroy() {
|
||||||
|
if ( currentPool ) vkDestroyDescriptorPool(device, currentPool, nullptr);
|
||||||
|
for ( auto p : usedPools ) vkDestroyDescriptorPool(device, p, nullptr);
|
||||||
|
usedPools.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
VkDescriptorPool ext::vulkan::DescriptorAllocator::createPool() {
|
||||||
|
VkDescriptorPoolCreateInfo poolInfo = {};
|
||||||
|
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
|
poolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
||||||
|
poolInfo.maxSets = 1000;
|
||||||
|
poolInfo.poolSizeCount = (uint32_t) poolSizes.size();
|
||||||
|
poolInfo.pPoolSizes = poolSizes.data();
|
||||||
|
|
||||||
|
VkDescriptorPool pool;
|
||||||
|
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &poolInfo, nullptr, &pool));
|
||||||
|
return pool;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ext::vulkan::DescriptorAllocator::allocate( VkDescriptorSet* set, VkDescriptorSetLayout layout ) {
|
||||||
|
if ( currentPool == VK_NULL_HANDLE ) currentPool = createPool();
|
||||||
|
|
||||||
|
VkDescriptorSetAllocateInfo allocInfo = {};
|
||||||
|
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
|
allocInfo.descriptorPool = currentPool;
|
||||||
|
allocInfo.descriptorSetCount = 1;
|
||||||
|
allocInfo.pSetLayouts = &layout;
|
||||||
|
|
||||||
|
VkResult result = vkAllocateDescriptorSets(device, &allocInfo, set);
|
||||||
|
|
||||||
|
if ( result == VK_ERROR_OUT_OF_POOL_MEMORY || result == VK_ERROR_FRAGMENTED_POOL ) {
|
||||||
|
usedPools.push_back(currentPool);
|
||||||
|
currentPool = createPool();
|
||||||
|
allocInfo.descriptorPool = currentPool;
|
||||||
|
|
||||||
|
result = vkAllocateDescriptorSets(device, &allocInfo, set);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result == VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -12,6 +12,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
#define USE_SHARED_PIPELINES 0
|
||||||
|
|
||||||
#define VK_DEBUG_VALIDATION_MESSAGE(...)\
|
#define VK_DEBUG_VALIDATION_MESSAGE(...)\
|
||||||
// VK_VALIDATION_MESSAGE(x);
|
// VK_VALIDATION_MESSAGE(x);
|
||||||
|
|
||||||
@ -19,6 +21,8 @@ namespace {
|
|||||||
uint32_t VERTEX_BUFFER_BIND_ID = 0;
|
uint32_t VERTEX_BUFFER_BIND_ID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uf::stl::unordered_map<ext::vulkan::GraphicDescriptor, ext::vulkan::Pipeline> ext::vulkan::Pipeline::pipelines;
|
||||||
|
|
||||||
PFN_vkGetBufferDeviceAddressKHR ext::vulkan::vkGetBufferDeviceAddressKHR = NULL; // = reinterpret_cast<PFN_vkGetBufferDeviceAddressKHR>(vkGetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR"));
|
PFN_vkGetBufferDeviceAddressKHR ext::vulkan::vkGetBufferDeviceAddressKHR = NULL; // = reinterpret_cast<PFN_vkGetBufferDeviceAddressKHR>(vkGetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR"));
|
||||||
PFN_vkCmdBuildAccelerationStructuresKHR ext::vulkan::vkCmdBuildAccelerationStructuresKHR = NULL; // = reinterpret_cast<PFN_vkCmdBuildAccelerationStructuresKHR>(vkGetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR"));
|
PFN_vkCmdBuildAccelerationStructuresKHR ext::vulkan::vkCmdBuildAccelerationStructuresKHR = NULL; // = reinterpret_cast<PFN_vkCmdBuildAccelerationStructuresKHR>(vkGetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR"));
|
||||||
PFN_vkBuildAccelerationStructuresKHR ext::vulkan::vkBuildAccelerationStructuresKHR = NULL; // = reinterpret_cast<PFN_vkBuildAccelerationStructuresKHR>(vkGetDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR"));
|
PFN_vkBuildAccelerationStructuresKHR ext::vulkan::vkBuildAccelerationStructuresKHR = NULL; // = reinterpret_cast<PFN_vkBuildAccelerationStructuresKHR>(vkGetDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR"));
|
||||||
@ -36,12 +40,13 @@ void ext::vulkan::Pipeline::initialize( const Graphic& graphic ) {
|
|||||||
return this->initialize( graphic, graphic.descriptor );
|
return this->initialize( graphic, graphic.descriptor );
|
||||||
}
|
}
|
||||||
void ext::vulkan::Pipeline::initialize( const Graphic& graphic, const GraphicDescriptor& descriptor ) {
|
void ext::vulkan::Pipeline::initialize( const Graphic& graphic, const GraphicDescriptor& descriptor ) {
|
||||||
|
if ( pipeline != VK_NULL_HANDLE ) return;
|
||||||
|
|
||||||
this->device = graphic.device;
|
this->device = graphic.device;
|
||||||
this->descriptor = descriptor;
|
this->descriptor = descriptor;
|
||||||
this->metadata.type = descriptor.pipeline;
|
|
||||||
Device& device = *graphic.device;
|
Device& device = *graphic.device;
|
||||||
|
|
||||||
auto shaders = getShaders( graphic.material.shaders, descriptor.pipeline );
|
auto shaders = graphic.material.getShaders( descriptor.pipeline );
|
||||||
assert( shaders.size() > 0 );
|
assert( shaders.size() > 0 );
|
||||||
|
|
||||||
uint32_t subpass = descriptor.subpass;
|
uint32_t subpass = descriptor.subpass;
|
||||||
@ -78,20 +83,6 @@ void ext::vulkan::Pipeline::initialize( const Graphic& graphic, const GraphicDes
|
|||||||
offset += len;
|
offset += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ( auto& descriptor : descriptorSetLayoutBindings ) {
|
|
||||||
if ( descriptorTypes.count( descriptor.descriptorType ) < 0 ) descriptorTypes[descriptor.descriptorType] = 0;
|
|
||||||
descriptorTypes[descriptor.descriptorType] += descriptor.descriptorCount;
|
|
||||||
}
|
|
||||||
for ( auto pair : descriptorTypes ) {
|
|
||||||
poolSizes.emplace_back(ext::vulkan::initializers::descriptorPoolSize(pair.first, pair.second));
|
|
||||||
}
|
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo = ext::vulkan::initializers::descriptorPoolCreateInfo(
|
|
||||||
poolSizes.size(),
|
|
||||||
poolSizes.data(),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &descriptorPool));
|
|
||||||
VK_REGISTER_HANDLE( descriptorPool );
|
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorLayout = ext::vulkan::initializers::descriptorSetLayoutCreateInfo(
|
VkDescriptorSetLayoutCreateInfo descriptorLayout = ext::vulkan::initializers::descriptorSetLayoutCreateInfo(
|
||||||
descriptorSetLayoutBindings.data(),
|
descriptorSetLayoutBindings.data(),
|
||||||
@ -100,13 +91,6 @@ void ext::vulkan::Pipeline::initialize( const Graphic& graphic, const GraphicDes
|
|||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout( device, &descriptorLayout, nullptr, &descriptorSetLayout ));
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout( device, &descriptorLayout, nullptr, &descriptorSetLayout ));
|
||||||
VK_REGISTER_HANDLE( descriptorSetLayout );
|
VK_REGISTER_HANDLE( descriptorSetLayout );
|
||||||
|
|
||||||
VkDescriptorSetAllocateInfo allocInfo = ext::vulkan::initializers::descriptorSetAllocateInfo(
|
|
||||||
descriptorPool,
|
|
||||||
&descriptorSetLayout,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSet));
|
|
||||||
|
|
||||||
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = ext::vulkan::initializers::pipelineLayoutCreateInfo(
|
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = ext::vulkan::initializers::pipelineLayoutCreateInfo(
|
||||||
&descriptorSetLayout,
|
&descriptorSetLayout,
|
||||||
1
|
1
|
||||||
@ -393,10 +377,7 @@ PIPELINE_INITIALIZATION_INVALID:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void ext::vulkan::Pipeline::record( const Graphic& graphic, VkCommandBuffer commandBuffer, size_t pass, size_t draw, size_t offset ) const {
|
void ext::vulkan::Pipeline::record( const Graphic& graphic, VkCommandBuffer commandBuffer, size_t pass, size_t draw, size_t offset ) const {
|
||||||
return record( graphic, descriptor, commandBuffer, pass, draw, offset );
|
auto shaders = graphic.material.getShaders( descriptor.pipeline );
|
||||||
}
|
|
||||||
void ext::vulkan::Pipeline::record( const Graphic& graphic, const GraphicDescriptor& descriptor, VkCommandBuffer commandBuffer, size_t pass, size_t draw, size_t offset ) const {
|
|
||||||
auto shaders = getShaders( graphic.material.shaders, descriptor.pipeline );
|
|
||||||
|
|
||||||
// create dynamic offset ranges
|
// create dynamic offset ranges
|
||||||
STATIC_THREAD_LOCAL(uf::stl::vector<uint32_t>, dynamicOffsets);
|
STATIC_THREAD_LOCAL(uf::stl::vector<uint32_t>, dynamicOffsets);
|
||||||
@ -440,6 +421,91 @@ void ext::vulkan::Pipeline::record( const Graphic& graphic, const GraphicDescrip
|
|||||||
vkCmdPushConstants( commandBuffer, pipelineLayout, shader->descriptor.stage, 0, size, data );
|
vkCmdPushConstants( commandBuffer, pipelineLayout, shader->descriptor.stage, 0, size, data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Bind the rendering pipeline
|
||||||
|
// The pipeline (state object) contains all states of the rendering pipeline, binding it will set all the states specified at pipeline creation time
|
||||||
|
vkCmdBindPipeline(commandBuffer, (VkPipelineBindPoint) descriptor.bind.point, pipeline);
|
||||||
|
}
|
||||||
|
void ext::vulkan::Pipeline::destroy() {
|
||||||
|
if ( aliased ) return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ( descriptorPool != VK_NULL_HANDLE) {
|
||||||
|
vkDestroyDescriptorPool( *device, descriptorPool, nullptr );
|
||||||
|
VK_UNREGISTER_HANDLE( descriptorPool );
|
||||||
|
descriptorPool = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if ( pipelineLayout != VK_NULL_HANDLE ) {
|
||||||
|
vkDestroyPipelineLayout( *device, pipelineLayout, nullptr );
|
||||||
|
VK_UNREGISTER_HANDLE( pipelineLayout );
|
||||||
|
pipelineLayout = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
if ( pipeline != VK_NULL_HANDLE ) {
|
||||||
|
vkDestroyPipeline( *device, pipeline, nullptr );
|
||||||
|
VK_UNREGISTER_HANDLE( pipeline );
|
||||||
|
pipeline = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
if ( descriptorSetLayout != VK_NULL_HANDLE ) {
|
||||||
|
vkDestroyDescriptorSetLayout( *device, descriptorSetLayout, nullptr );
|
||||||
|
VK_UNREGISTER_HANDLE( descriptorSetLayout );
|
||||||
|
descriptorSetLayout = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ( settings::experimental::dedicatedThread ) ext::vulkan::states::rebuild = true;
|
||||||
|
/*
|
||||||
|
if ( ext::vulkan::hasRenderMode(descriptor.renderMode, true) ) {
|
||||||
|
RenderMode& renderMode = ext::vulkan::getRenderMode(descriptor.renderMode, true);
|
||||||
|
renderMode.rebuild = true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void ext::vulkan::DescriptorSet::initialize( const Graphic& graphic ) {
|
||||||
|
initialize( graphic, graphic.descriptor );
|
||||||
|
}
|
||||||
|
void ext::vulkan::DescriptorSet::initialize( const Graphic& graphic, const GraphicDescriptor& descriptor ) {
|
||||||
|
if ( descriptorSet != VK_NULL_HANDLE ) return;
|
||||||
|
|
||||||
|
this->device = graphic.device;
|
||||||
|
this->descriptor = descriptor;
|
||||||
|
|
||||||
|
auto& pipeline = graphic.getPipeline( descriptor );
|
||||||
|
UF_ASSERT(device->descriptorAllocator.allocate( &descriptorSet, pipeline.descriptorSetLayout ));
|
||||||
|
}
|
||||||
|
void ext::vulkan::DescriptorSet::record( const Graphic& graphic, VkCommandBuffer commandBuffer, size_t pass, size_t draw, size_t offset ) const {
|
||||||
|
return record( graphic, descriptor, commandBuffer, pass, draw, offset );
|
||||||
|
}
|
||||||
|
void ext::vulkan::DescriptorSet::record( const Graphic& graphic, const GraphicDescriptor& descriptor, VkCommandBuffer commandBuffer, size_t pass, size_t draw, size_t offset ) const {
|
||||||
|
auto shaders = graphic.material.getShaders( descriptor.pipeline );
|
||||||
|
auto& pipeline = graphic.getPipeline( descriptor );
|
||||||
|
|
||||||
|
// create dynamic offset ranges
|
||||||
|
STATIC_THREAD_LOCAL(uf::stl::vector<uint32_t>, dynamicOffsets);
|
||||||
|
|
||||||
|
RenderMode& renderMode = ext::vulkan::getRenderMode(descriptor.renderMode, true);
|
||||||
|
|
||||||
|
bool bound = false;
|
||||||
|
for ( auto* shader : shaders ) {
|
||||||
|
// compute shaders
|
||||||
|
if ( shader->descriptor.stage == VK_SHADER_STAGE_COMPUTE_BIT ) {
|
||||||
|
if ( descriptor.bind.point == VK_PIPELINE_BIND_POINT_COMPUTE ) bound = true;
|
||||||
|
else continue;
|
||||||
|
// raytrace shaders
|
||||||
|
} else if (
|
||||||
|
shader->descriptor.stage == VK_SHADER_STAGE_RAYGEN_BIT_KHR ||
|
||||||
|
shader->descriptor.stage == VK_SHADER_STAGE_MISS_BIT_KHR ||
|
||||||
|
shader->descriptor.stage == VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR ||
|
||||||
|
shader->descriptor.stage == VK_SHADER_STAGE_ANY_HIT_BIT_KHR ||
|
||||||
|
shader->descriptor.stage == VK_SHADER_STAGE_INTERSECTION_BIT_KHR
|
||||||
|
) {
|
||||||
|
if ( descriptor.bind.point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR ) bound = true;
|
||||||
|
else continue;
|
||||||
|
// anything else
|
||||||
|
} else {
|
||||||
|
if ( descriptor.bind.point == VK_PIPELINE_BIND_POINT_GRAPHICS ) bound = true;
|
||||||
|
else continue;
|
||||||
|
}
|
||||||
|
|
||||||
dynamicOffsets.insert( dynamicOffsets.end(), shader->metadata.dynamicRanges.begin(), shader->metadata.dynamicRanges.end() );
|
dynamicOffsets.insert( dynamicOffsets.end(), shader->metadata.dynamicRanges.begin(), shader->metadata.dynamicRanges.end() );
|
||||||
}
|
}
|
||||||
@ -455,13 +521,10 @@ void ext::vulkan::Pipeline::record( const Graphic& graphic, const GraphicDescrip
|
|||||||
|
|
||||||
// Bind descriptor sets describing shader binding points
|
// Bind descriptor sets describing shader binding points
|
||||||
#if VK_UBO_USE_N_BUFFERS
|
#if VK_UBO_USE_N_BUFFERS
|
||||||
vkCmdBindDescriptorSets(commandBuffer, (VkPipelineBindPoint) descriptor.bind.point, pipelineLayout, 0, 1, &descriptorSet, dynamicOffsets.size(), dynamicOffsets.data());
|
vkCmdBindDescriptorSets(commandBuffer, (VkPipelineBindPoint) descriptor.bind.point, pipeline.pipelineLayout, 0, 1, &descriptorSet, dynamicOffsets.size(), dynamicOffsets.data());
|
||||||
#else
|
#else
|
||||||
vkCmdBindDescriptorSets(commandBuffer, (VkPipelineBindPoint) descriptor.bind.point, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
vkCmdBindDescriptorSets(commandBuffer, (VkPipelineBindPoint) descriptor.bind.point, pipeline.pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
||||||
#endif
|
#endif
|
||||||
// Bind the rendering pipeline
|
|
||||||
// The pipeline (state object) contains all states of the rendering pipeline, binding it will set all the states specified at pipeline creation time
|
|
||||||
vkCmdBindPipeline(commandBuffer, (VkPipelineBindPoint)descriptor.bind.point, pipeline);
|
|
||||||
|
|
||||||
uint32_t width = descriptor.bind.width ? descriptor.bind.width : ext::vulkan::settings::width;
|
uint32_t width = descriptor.bind.width ? descriptor.bind.width : ext::vulkan::settings::width;
|
||||||
uint32_t height = descriptor.bind.height ? descriptor.bind.height : ext::vulkan::settings::height;
|
uint32_t height = descriptor.bind.height ? descriptor.bind.height : ext::vulkan::settings::height;
|
||||||
@ -470,10 +533,10 @@ void ext::vulkan::Pipeline::record( const Graphic& graphic, const GraphicDescrip
|
|||||||
if ( descriptor.bind.point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR ) {
|
if ( descriptor.bind.point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR ) {
|
||||||
uf::renderer::vkCmdTraceRaysKHR(
|
uf::renderer::vkCmdTraceRaysKHR(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
&sbtEntries[0],
|
&pipeline.sbtEntries[0],
|
||||||
&sbtEntries[1],
|
&pipeline.sbtEntries[1],
|
||||||
&sbtEntries[2],
|
&pipeline.sbtEntries[2],
|
||||||
&sbtEntries[3],
|
&pipeline.sbtEntries[3],
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
1
|
1
|
||||||
@ -496,18 +559,18 @@ void ext::vulkan::Pipeline::record( const Graphic& graphic, const GraphicDescrip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ext::vulkan::Pipeline::update( const Graphic& graphic ) {
|
void ext::vulkan::DescriptorSet::update( const Graphic& graphic ) {
|
||||||
return this->update( graphic, descriptor );
|
return this->update( graphic, descriptor );
|
||||||
}
|
}
|
||||||
void ext::vulkan::Pipeline::update( const Graphic& graphic, const GraphicDescriptor& descriptor ) {
|
void ext::vulkan::DescriptorSet::update( const Graphic& graphic, const GraphicDescriptor& descriptor ) {
|
||||||
//
|
//
|
||||||
if ( descriptorSet == VK_NULL_HANDLE ) return;
|
if ( descriptorSet == VK_NULL_HANDLE ) this->initialize( graphic, descriptor );
|
||||||
this->descriptor = descriptor;
|
this->descriptor = descriptor;
|
||||||
|
|
||||||
RenderMode& renderMode = ext::vulkan::getRenderMode(descriptor.renderMode, true);
|
RenderMode& renderMode = ext::vulkan::getRenderMode(descriptor.renderMode, true);
|
||||||
auto& renderTarget = renderMode.getRenderTarget(/*descriptor.renderTarget*/);
|
auto& renderTarget = renderMode.getRenderTarget(/*descriptor.renderTarget*/);
|
||||||
|
|
||||||
auto shaders = getShaders( graphic.material.shaders, descriptor.pipeline );
|
auto shaders = graphic.material.getShaders( descriptor.pipeline );
|
||||||
uf::stl::vector<VkWriteDescriptorSet> writeDescriptorSets;
|
uf::stl::vector<VkWriteDescriptorSet> writeDescriptorSets;
|
||||||
uf::stl::vector<uf::renderer::AccelerationStructure> tlases;
|
uf::stl::vector<uf::renderer::AccelerationStructure> tlases;
|
||||||
|
|
||||||
@ -887,7 +950,7 @@ PIPELINE_UPDATE_INVALID:
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void ext::vulkan::Pipeline::collectBuffers( const Shader& shader, const RenderMode& renderMode, const Graphic& graphic, const std::function<void(const Buffer&)>& lambda ) const {
|
void ext::vulkan::DescriptorSet::collectBuffers( const Shader& shader, const RenderMode& renderMode, const Graphic& graphic, const std::function<void(const Buffer&)>& lambda ) const {
|
||||||
// add aliased-by-name buffers
|
// add aliased-by-name buffers
|
||||||
for ( auto& descriptor : shader.metadata.aliases.buffers ) {
|
for ( auto& descriptor : shader.metadata.aliases.buffers ) {
|
||||||
auto matches = uf::string::match(descriptor.name, R"(/^(.+?)\[(\d+)\]$/)");
|
auto matches = uf::string::match(descriptor.name, R"(/^(.+?)\[(\d+)\]$/)");
|
||||||
@ -916,64 +979,21 @@ void ext::vulkan::Pipeline::collectBuffers( const Shader& shader, const RenderMo
|
|||||||
// add per-graphics buffers
|
// add per-graphics buffers
|
||||||
for ( auto& buffer : graphic.buffers ) lambda( buffer );
|
for ( auto& buffer : graphic.buffers ) lambda( buffer );
|
||||||
}
|
}
|
||||||
void ext::vulkan::Pipeline::destroy() {
|
|
||||||
if ( aliased ) return;
|
|
||||||
|
|
||||||
if ( descriptorPool != VK_NULL_HANDLE) {
|
void ext::vulkan::DescriptorSet::destroy() {
|
||||||
vkDestroyDescriptorPool( *device, descriptorPool, nullptr );
|
// no-op
|
||||||
VK_UNREGISTER_HANDLE( descriptorPool );
|
|
||||||
descriptorPool = VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
if ( pipelineLayout != VK_NULL_HANDLE ) {
|
|
||||||
vkDestroyPipelineLayout( *device, pipelineLayout, nullptr );
|
|
||||||
VK_UNREGISTER_HANDLE( pipelineLayout );
|
|
||||||
pipelineLayout = VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
if ( pipeline != VK_NULL_HANDLE ) {
|
|
||||||
vkDestroyPipeline( *device, pipeline, nullptr );
|
|
||||||
VK_UNREGISTER_HANDLE( pipeline );
|
|
||||||
pipeline = VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
if ( descriptorSetLayout != VK_NULL_HANDLE ) {
|
|
||||||
vkDestroyDescriptorSetLayout( *device, descriptorSetLayout, nullptr );
|
|
||||||
VK_UNREGISTER_HANDLE( descriptorSetLayout );
|
|
||||||
descriptorSetLayout = VK_NULL_HANDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ( settings::experimental::dedicatedThread ) ext::vulkan::states::rebuild = true;
|
uf::stl::vector<const ext::vulkan::Shader*> ext::vulkan::Material::getShaders( const uf::stl::string& type ) const {
|
||||||
/*
|
|
||||||
if ( ext::vulkan::hasRenderMode(descriptor.renderMode, true) ) {
|
|
||||||
RenderMode& renderMode = ext::vulkan::getRenderMode(descriptor.renderMode, true);
|
|
||||||
renderMode.rebuild = true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
uf::stl::vector<ext::vulkan::Shader*> ext::vulkan::Pipeline::getShaders( uf::stl::vector<ext::vulkan::Shader>& shaders, const uf::stl::string& type ) {
|
|
||||||
uf::stl::unordered_map<uf::stl::string, ext::vulkan::Shader*> map;
|
|
||||||
uf::stl::vector<ext::vulkan::Shader*> res;
|
|
||||||
bool isCompute = false;
|
|
||||||
for ( auto& shader : shaders ) {
|
|
||||||
if ( shader.metadata.pipeline != "" && shader.metadata.pipeline != (type == "" ? metadata.type : type) ) continue;
|
|
||||||
if ( shader.descriptor.stage == VK_SHADER_STAGE_COMPUTE_BIT ) isCompute = true;
|
|
||||||
}
|
|
||||||
for ( auto& shader : shaders ) {
|
|
||||||
if ( shader.metadata.pipeline != "" && shader.metadata.pipeline != (type == "" ? metadata.type : type) ) continue;
|
|
||||||
if ( isCompute && shader.descriptor.stage != VK_SHADER_STAGE_COMPUTE_BIT ) continue;
|
|
||||||
map[shader.metadata.type] = &shader;
|
|
||||||
}
|
|
||||||
for ( auto pair : map ) res.insert( res.begin(), pair.second);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
uf::stl::vector<const ext::vulkan::Shader*> ext::vulkan::Pipeline::getShaders( const uf::stl::vector<ext::vulkan::Shader>& shaders, const uf::stl::string& type ) const {
|
|
||||||
uf::stl::unordered_map<uf::stl::string, const ext::vulkan::Shader*> map;
|
uf::stl::unordered_map<uf::stl::string, const ext::vulkan::Shader*> map;
|
||||||
uf::stl::vector<const ext::vulkan::Shader*> res;
|
uf::stl::vector<const ext::vulkan::Shader*> res;
|
||||||
bool isCompute = false;
|
bool isCompute = false;
|
||||||
for ( auto& shader : shaders ) {
|
for ( auto& shader : shaders ) {
|
||||||
if ( shader.metadata.pipeline != "" && shader.metadata.pipeline != (type == "" ? metadata.type : type) ) continue;
|
if ( shader.metadata.pipeline != "" && shader.metadata.pipeline != type ) continue;
|
||||||
if ( shader.descriptor.stage == VK_SHADER_STAGE_COMPUTE_BIT ) isCompute = true;
|
if ( shader.descriptor.stage == VK_SHADER_STAGE_COMPUTE_BIT ) isCompute = true;
|
||||||
}
|
}
|
||||||
for ( auto& shader : shaders ) {
|
for ( auto& shader : shaders ) {
|
||||||
if ( shader.metadata.pipeline != "" && shader.metadata.pipeline != (type == "" ? metadata.type : type) ) continue;
|
if ( shader.metadata.pipeline != "" && shader.metadata.pipeline != type ) continue;
|
||||||
if ( isCompute && shader.descriptor.stage != VK_SHADER_STAGE_COMPUTE_BIT ) continue;
|
if ( isCompute && shader.descriptor.stage != VK_SHADER_STAGE_COMPUTE_BIT ) continue;
|
||||||
map[shader.metadata.type] = &shader;
|
map[shader.metadata.type] = &shader;
|
||||||
}
|
}
|
||||||
@ -1041,6 +1061,8 @@ void ext::vulkan::Material::attachShader( const uf::stl::string& filename, VkSha
|
|||||||
metadata.json["shaders"][pipeline][type]["index"] = shaders.size() - 1;
|
metadata.json["shaders"][pipeline][type]["index"] = shaders.size() - 1;
|
||||||
metadata.json["shaders"][pipeline][type]["filename"] = filename;
|
metadata.json["shaders"][pipeline][type]["filename"] = filename;
|
||||||
metadata.shaders[pipeline+":"+type] = shaders.size() - 1;
|
metadata.shaders[pipeline+":"+type] = shaders.size() - 1;
|
||||||
|
|
||||||
|
uf::hash( metadata.hashes[pipeline], filename );
|
||||||
}
|
}
|
||||||
void ext::vulkan::Material::initializeShaders( const uf::stl::vector<std::pair<uf::stl::string, VkShaderStageFlagBits>>& layout, const uf::stl::string& pipeline ) {
|
void ext::vulkan::Material::initializeShaders( const uf::stl::vector<std::pair<uf::stl::string, VkShaderStageFlagBits>>& layout, const uf::stl::string& pipeline ) {
|
||||||
shaders.clear(); shaders.reserve( layout.size() );
|
shaders.clear(); shaders.reserve( layout.size() );
|
||||||
@ -1081,26 +1103,34 @@ void ext::vulkan::Graphic::initialize( const uf::stl::string& renderModeName ) {
|
|||||||
|
|
||||||
if ( this->accelerationStructures.tops.empty() ) this->accelerationStructures.tops.resize(2);
|
if ( this->accelerationStructures.tops.empty() ) this->accelerationStructures.tops.resize(2);
|
||||||
}
|
}
|
||||||
void ext::vulkan::Graphic::initializePipeline() {
|
void ext::vulkan::Graphic::initialize( const GraphicDescriptor& descriptor ) {
|
||||||
initializePipeline( this->descriptor, false );
|
update( descriptor );
|
||||||
}
|
}
|
||||||
ext::vulkan::Pipeline& ext::vulkan::Graphic::initializePipeline( const GraphicDescriptor& descriptor, bool update ) {
|
void ext::vulkan::Graphic::update() {
|
||||||
auto& pipeline = pipelines[descriptor];
|
// update descriptor
|
||||||
|
this->descriptor.material = material.metadata.hashes[descriptor.pipeline];
|
||||||
pipeline.initialize(*this, descriptor);
|
update( this->descriptor );
|
||||||
pipeline.update(*this, descriptor);
|
}
|
||||||
|
void ext::vulkan::Graphic::update( const GraphicDescriptor& descriptor ) {
|
||||||
|
initializePipeline( descriptor );
|
||||||
|
initializeDescriptorSet( descriptor );
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
material.validate();
|
material.validate();
|
||||||
|
}
|
||||||
|
void ext::vulkan::Graphic::initializePipeline() {
|
||||||
|
initializePipeline( this->descriptor );
|
||||||
|
}
|
||||||
|
ext::vulkan::Pipeline& ext::vulkan::Graphic::initializePipeline( const GraphicDescriptor& descriptor ) {
|
||||||
|
#if USE_SHARED_PIPELINES
|
||||||
|
auto& pipeline = Pipeline::pipelines[descriptor];
|
||||||
|
#else
|
||||||
|
auto& pipeline = pipelines[descriptor];
|
||||||
|
#endif
|
||||||
|
pipeline.initialize(*this, descriptor);
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
void ext::vulkan::Graphic::initializeMesh( uf::Mesh& mesh, bool buffer ) {
|
void ext::vulkan::Graphic::initializeMesh( uf::Mesh& mesh, bool buffer ) {
|
||||||
// generate indices if not found
|
|
||||||
// if ( mesh.index.count == 0 ) mesh.generateIndices();
|
|
||||||
// generate indirect data if not found
|
|
||||||
// if ( mesh.indirect.count == 0 ) mesh.generateIndirect();
|
|
||||||
// ensure our descriptors are proper
|
|
||||||
mesh.updateDescriptor();
|
mesh.updateDescriptor();
|
||||||
|
|
||||||
// copy descriptors
|
// copy descriptors
|
||||||
@ -1153,11 +1183,6 @@ void ext::vulkan::Graphic::initializeMesh( uf::Mesh& mesh, bool buffer ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool ext::vulkan::Graphic::updateMesh( uf::Mesh& mesh ) {
|
bool ext::vulkan::Graphic::updateMesh( uf::Mesh& mesh ) {
|
||||||
// generate indices if not found
|
|
||||||
// if ( mesh.index.count == 0 ) mesh.generateIndices();
|
|
||||||
// generate indirect data if not found
|
|
||||||
// if ( mesh.indirect.count == 0 ) mesh.generateIndirect();
|
|
||||||
// ensure our descriptors are proper
|
|
||||||
mesh.updateDescriptor();
|
mesh.updateDescriptor();
|
||||||
|
|
||||||
descriptor.inputs.vertex = mesh.vertex;
|
descriptor.inputs.vertex = mesh.vertex;
|
||||||
@ -1815,7 +1840,11 @@ void ext::vulkan::Graphic::generateTopAccelerationStructure( const uf::stl::vect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool ext::vulkan::Graphic::hasPipeline( const GraphicDescriptor& descriptor ) const {
|
bool ext::vulkan::Graphic::hasPipeline( const GraphicDescriptor& descriptor ) const {
|
||||||
|
#if USE_SHARED_PIPELINES
|
||||||
|
return Pipeline::pipelines.count( descriptor ) > 0;
|
||||||
|
#else
|
||||||
return pipelines.count( descriptor ) > 0;
|
return pipelines.count( descriptor ) > 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ext::vulkan::Pipeline& ext::vulkan::Graphic::getPipeline() {
|
ext::vulkan::Pipeline& ext::vulkan::Graphic::getPipeline() {
|
||||||
return getPipeline( descriptor );
|
return getPipeline( descriptor );
|
||||||
@ -1825,34 +1854,82 @@ const ext::vulkan::Pipeline& ext::vulkan::Graphic::getPipeline() const {
|
|||||||
}
|
}
|
||||||
ext::vulkan::Pipeline& ext::vulkan::Graphic::getPipeline( const GraphicDescriptor& descriptor ) {
|
ext::vulkan::Pipeline& ext::vulkan::Graphic::getPipeline( const GraphicDescriptor& descriptor ) {
|
||||||
if ( !hasPipeline(descriptor) ) return initializePipeline( descriptor );
|
if ( !hasPipeline(descriptor) ) return initializePipeline( descriptor );
|
||||||
|
#if USE_SHARED_PIPELINES
|
||||||
|
return Pipeline::pipelines[descriptor];
|
||||||
|
#else
|
||||||
return pipelines[descriptor];
|
return pipelines[descriptor];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
const ext::vulkan::Pipeline& ext::vulkan::Graphic::getPipeline( const GraphicDescriptor& descriptor ) const {
|
const ext::vulkan::Pipeline& ext::vulkan::Graphic::getPipeline( const GraphicDescriptor& descriptor ) const {
|
||||||
if ( !hasPipeline(descriptor) ) UF_EXCEPTION("does not have pipeline");
|
if ( !hasPipeline(descriptor) ) UF_EXCEPTION("does not have pipeline");
|
||||||
|
#if USE_SHARED_PIPELINES
|
||||||
|
return Pipeline::pipelines.at(descriptor);
|
||||||
|
#else
|
||||||
return pipelines.at(descriptor);
|
return pipelines.at(descriptor);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void ext::vulkan::Graphic::updatePipelines() {
|
bool ext::vulkan::Graphic::hasDescriptorSet( const GraphicDescriptor& descriptor ) const {
|
||||||
for ( auto pair : this->pipelines ) pair.second.update( *this );
|
return descriptorSets.count( descriptor ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ext::vulkan::Graphic::initializeDescriptorSet() {
|
||||||
|
initializeDescriptorSet( this->descriptor );
|
||||||
|
}
|
||||||
|
ext::vulkan::DescriptorSet& ext::vulkan::Graphic::initializeDescriptorSet( const GraphicDescriptor& descriptor ) {
|
||||||
|
auto& pipeline = getPipeline();
|
||||||
|
auto& descriptorSet = descriptorSets[descriptor];
|
||||||
|
|
||||||
|
// ensure pipeline exists (because we're passing this as const)
|
||||||
|
pipeline.initialize(*this, descriptor);
|
||||||
|
|
||||||
|
descriptorSet.initialize(*this, descriptor);
|
||||||
|
descriptorSet.update(*this, descriptor);
|
||||||
|
|
||||||
|
return descriptorSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
ext::vulkan::DescriptorSet& ext::vulkan::Graphic::getDescriptorSet() {
|
||||||
|
return getDescriptorSet( descriptor );
|
||||||
|
}
|
||||||
|
const ext::vulkan::DescriptorSet& ext::vulkan::Graphic::getDescriptorSet() const {
|
||||||
|
return getDescriptorSet( descriptor );
|
||||||
|
}
|
||||||
|
ext::vulkan::DescriptorSet& ext::vulkan::Graphic::getDescriptorSet( const GraphicDescriptor& descriptor ) {
|
||||||
|
if ( !hasDescriptorSet(descriptor) ) return initializeDescriptorSet( descriptor );
|
||||||
|
return descriptorSets[descriptor];
|
||||||
|
}
|
||||||
|
const ext::vulkan::DescriptorSet& ext::vulkan::Graphic::getDescriptorSet( const GraphicDescriptor& descriptor ) const {
|
||||||
|
if ( !hasDescriptorSet(descriptor) ) UF_EXCEPTION("does not have descriptor set");
|
||||||
|
return descriptorSets.at(descriptor);
|
||||||
}
|
}
|
||||||
void ext::vulkan::Graphic::record( VkCommandBuffer commandBuffer, size_t pass, size_t draw, size_t offset ) const {
|
void ext::vulkan::Graphic::record( VkCommandBuffer commandBuffer, size_t pass, size_t draw, size_t offset ) const {
|
||||||
return this->record( commandBuffer, descriptor, pass, draw, offset );
|
return this->record( commandBuffer, descriptor, pass, draw, offset );
|
||||||
}
|
}
|
||||||
void ext::vulkan::Graphic::record( VkCommandBuffer commandBuffer, const GraphicDescriptor& descriptor, size_t pass, size_t draw, size_t offset ) const {
|
void ext::vulkan::Graphic::record( VkCommandBuffer commandBuffer, const GraphicDescriptor& descriptor, size_t pass, size_t draw, size_t offset ) const {
|
||||||
if ( !process ) return;
|
if ( !process ) return;
|
||||||
if ( !this->hasPipeline( descriptor ) ) {
|
#if USE_SHARED_PIPELINES
|
||||||
|
if ( Pipeline::pipelines.count( descriptor ) == 0 ) {
|
||||||
|
Pipeline::pipelines[descriptor].initialize(*this, descriptor);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if ( !hasPipeline( descriptor ) ) {
|
||||||
// UF_MSG_DEBUG("{} has no valid pipeline ({}:{}:{})", (void*) this, descriptor.renderMode, descriptor.renderTarget, descriptor.pipeline);
|
// UF_MSG_DEBUG("{} has no valid pipeline ({}:{}:{})", (void*) this, descriptor.renderMode, descriptor.renderTarget, descriptor.pipeline);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ( !hasDescriptorSet( descriptor ) ) {
|
||||||
|
// UF_MSG_DEBUG("{} has no valid descriptor set ({}:{}:{})", (void*) this, descriptor.renderMode, descriptor.renderTarget, descriptor.pipeline);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& pipeline = this->getPipeline( descriptor );
|
auto& pipeline = this->getPipeline( descriptor );
|
||||||
if ( pipeline.descriptorSet == VK_NULL_HANDLE ) {
|
auto& descriptorSet = this->getDescriptorSet( descriptor );
|
||||||
//UF_MSG_DEBUG("{} has no valid pipeline descriptor set ({}:{}:{})", (void*) this, descriptor.renderMode, descriptor.renderTarget, descriptor.pipeline);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( !pipeline.metadata.process ) return;
|
|
||||||
pipeline.record(*this, descriptor, commandBuffer, pass, draw, offset);
|
|
||||||
|
|
||||||
auto shaders = pipeline.getShaders( material.shaders, descriptor.pipeline );
|
if ( !descriptorSet.metadata.process ) return;
|
||||||
|
|
||||||
|
pipeline.record( *this, commandBuffer, pass, draw, offset );
|
||||||
|
descriptorSet.record( *this, descriptor, commandBuffer, pass, draw, offset );
|
||||||
|
|
||||||
|
auto shaders = material.getShaders( descriptor.pipeline );
|
||||||
for ( auto* shader : shaders ) {
|
for ( auto* shader : shaders ) {
|
||||||
if ( shader->descriptor.stage == VK_SHADER_STAGE_COMPUTE_BIT ) return;
|
if ( shader->descriptor.stage == VK_SHADER_STAGE_COMPUTE_BIT ) return;
|
||||||
if (
|
if (
|
||||||
@ -1986,11 +2063,12 @@ void ext::vulkan::Graphic::destroy() {
|
|||||||
}
|
}
|
||||||
accelerationStructures.tops.clear();
|
accelerationStructures.tops.clear();
|
||||||
}
|
}
|
||||||
for ( auto& pair : pipelines ) {
|
for ( auto& pair : pipelines ) pair.second.destroy();
|
||||||
pair.second.destroy();
|
|
||||||
}
|
|
||||||
pipelines.clear();
|
pipelines.clear();
|
||||||
|
|
||||||
|
for ( auto& pair : descriptorSets ) pair.second.destroy();
|
||||||
|
descriptorSets.clear();
|
||||||
|
|
||||||
material.destroy();
|
material.destroy();
|
||||||
ext::vulkan::Buffers::destroy();
|
ext::vulkan::Buffers::destroy();
|
||||||
// ext::vulkan::states::rebuild = true;
|
// ext::vulkan::states::rebuild = true;
|
||||||
@ -2018,7 +2096,7 @@ void ext::vulkan::GraphicDescriptor::parse( ext::json::Value& metadata ) {
|
|||||||
}
|
}
|
||||||
ext::vulkan::GraphicDescriptor::hash_t ext::vulkan::GraphicDescriptor::hash() const {
|
ext::vulkan::GraphicDescriptor::hash_t ext::vulkan::GraphicDescriptor::hash() const {
|
||||||
size_t seed{};
|
size_t seed{};
|
||||||
uf::hash( seed, aux, subpass, renderMode, renderTarget, pipeline, topology, cullMode, fill, lineWidth, frontFace, depth.test, depth.write, depth.operation, depth.bias.enable, depth.bias.constant, depth.bias.slope, depth.bias.clamp );
|
uf::hash( seed, aux, subpass, renderMode, renderTarget, material, pipeline, topology, cullMode, fill, lineWidth, frontFace, depth.test, depth.write, depth.operation, depth.bias.enable, depth.bias.constant, depth.bias.slope, depth.bias.clamp );
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -351,7 +351,7 @@ void ext::vulkan::RenderMode::bindPipelines( const uf::stl::vector<ext::vulkan::
|
|||||||
size_t shaders = 0;
|
size_t shaders = 0;
|
||||||
for ( auto& shader : graphic.material.shaders ) if ( shader.metadata.pipeline == descriptor.pipeline ) ++shaders;
|
for ( auto& shader : graphic.material.shaders ) if ( shader.metadata.pipeline == descriptor.pipeline ) ++shaders;
|
||||||
if ( shaders == 0 ) continue;
|
if ( shaders == 0 ) continue;
|
||||||
graphic.initializePipeline( descriptor );
|
graphic.update( descriptor );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -526,11 +526,7 @@ void ext::vulkan::DeferredRenderMode::build( bool resized ) {
|
|||||||
{
|
{
|
||||||
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
||||||
|
|
||||||
if ( blitter.hasPipeline( blitter.descriptor ) ){
|
blitter.update( blitter.descriptor );
|
||||||
blitter.getPipeline( blitter.descriptor ).update( blitter, blitter.descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( blitter.descriptor );
|
|
||||||
}
|
|
||||||
|
|
||||||
descriptor.renderMode = "";
|
descriptor.renderMode = "";
|
||||||
descriptor.bind.width = width;
|
descriptor.bind.width = width;
|
||||||
@ -546,11 +542,7 @@ void ext::vulkan::DeferredRenderMode::build( bool resized ) {
|
|||||||
descriptor.subpass = 0;
|
descriptor.subpass = 0;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
}
|
}
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( settings::pipelines::bloom ) {
|
if ( settings::pipelines::bloom ) {
|
||||||
@ -558,11 +550,7 @@ void ext::vulkan::DeferredRenderMode::build( bool resized ) {
|
|||||||
descriptor.pipeline = "bloom-down";
|
descriptor.pipeline = "bloom-down";
|
||||||
descriptor.subpass = 0;
|
descriptor.subpass = 0;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( settings::pipelines::bloom ) {
|
if ( settings::pipelines::bloom ) {
|
||||||
@ -570,11 +558,7 @@ void ext::vulkan::DeferredRenderMode::build( bool resized ) {
|
|||||||
descriptor.pipeline = "bloom-up";
|
descriptor.pipeline = "bloom-up";
|
||||||
descriptor.subpass = 0;
|
descriptor.subpass = 0;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( settings::pipelines::dof ) {
|
if ( settings::pipelines::dof ) {
|
||||||
@ -582,11 +566,7 @@ void ext::vulkan::DeferredRenderMode::build( bool resized ) {
|
|||||||
descriptor.pipeline = "dof-down";
|
descriptor.pipeline = "dof-down";
|
||||||
descriptor.subpass = 0;
|
descriptor.subpass = 0;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( settings::pipelines::dof ) {
|
if ( settings::pipelines::dof ) {
|
||||||
@ -594,11 +574,7 @@ void ext::vulkan::DeferredRenderMode::build( bool resized ) {
|
|||||||
descriptor.pipeline = "dof-up";
|
descriptor.pipeline = "dof-up";
|
||||||
descriptor.subpass = 0;
|
descriptor.subpass = 0;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( settings::pipelines::culling ) {
|
if ( settings::pipelines::culling ) {
|
||||||
@ -606,11 +582,7 @@ void ext::vulkan::DeferredRenderMode::build( bool resized ) {
|
|||||||
descriptor.pipeline = "depth-pyramid";
|
descriptor.pipeline = "depth-pyramid";
|
||||||
descriptor.subpass = 0;
|
descriptor.subpass = 0;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -371,11 +371,7 @@ void ext::vulkan::RenderTargetRenderMode::build( bool resized ) {
|
|||||||
blitter.descriptor.bind.width = width;
|
blitter.descriptor.bind.width = width;
|
||||||
blitter.descriptor.bind.height = height;
|
blitter.descriptor.bind.height = height;
|
||||||
|
|
||||||
if ( !blitter.hasPipeline( blitter.descriptor ) ) {
|
blitter.update( blitter.descriptor );
|
||||||
blitter.initializePipeline( blitter.descriptor );
|
|
||||||
} else if ( blitter.hasPipeline( blitter.descriptor ) ){
|
|
||||||
blitter.getPipeline( blitter.descriptor ).update( blitter, blitter.descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( metadata.type == uf::renderer::settings::pipelines::names::vxgi ) {
|
if ( metadata.type == uf::renderer::settings::pipelines::names::vxgi ) {
|
||||||
@ -383,11 +379,7 @@ void ext::vulkan::RenderTargetRenderMode::build( bool resized ) {
|
|||||||
//descriptor.pipeline = "lighting";
|
//descriptor.pipeline = "lighting";
|
||||||
descriptor.subpass = -1;
|
descriptor.subpass = -1;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( metadata.type == uf::renderer::settings::pipelines::names::vxgi ) {
|
if ( metadata.type == uf::renderer::settings::pipelines::names::vxgi ) {
|
||||||
@ -395,11 +387,7 @@ void ext::vulkan::RenderTargetRenderMode::build( bool resized ) {
|
|||||||
descriptor.pipeline = "mipmap";
|
descriptor.pipeline = "mipmap";
|
||||||
descriptor.subpass = -1;
|
descriptor.subpass = -1;
|
||||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.update( descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
} else {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -494,11 +494,14 @@ void ext::vulkan::initialize( bool soft ) {
|
|||||||
}
|
}
|
||||||
void ext::vulkan::tick() {
|
void ext::vulkan::tick() {
|
||||||
// ext::vulkan::mutex.lock();
|
// ext::vulkan::mutex.lock();
|
||||||
if ( ext::vulkan::states::resized || ext::vulkan::settings::experimental::rebuildOnTickBegin ) {
|
if ( ext::vulkan::states::resized ) {
|
||||||
synchronize(0b11);
|
// synchronize(0b11);
|
||||||
ext::vulkan::states::rebuild = true;
|
ext::vulkan::states::rebuild = true;
|
||||||
::skip = true;
|
::skip = true;
|
||||||
}
|
}
|
||||||
|
if ( ext::vulkan::settings::experimental::rebuildOnTickBegin ) {
|
||||||
|
ext::vulkan::states::rebuild = true;
|
||||||
|
}
|
||||||
|
|
||||||
ext::fsr::tick();
|
ext::fsr::tick();
|
||||||
|
|
||||||
@ -519,7 +522,7 @@ void ext::vulkan::tick() {
|
|||||||
if ( entity->hasComponent<uf::Graphic>() ) {
|
if ( entity->hasComponent<uf::Graphic>() ) {
|
||||||
ext::vulkan::Graphic& graphic = entity->getComponent<uf::Graphic>();
|
ext::vulkan::Graphic& graphic = entity->getComponent<uf::Graphic>();
|
||||||
if ( graphic.initialized || !graphic.process || graphic.initialized ) continue;
|
if ( graphic.initialized || !graphic.process || graphic.initialized ) continue;
|
||||||
graphic.initializePipeline();
|
graphic.update();
|
||||||
ext::vulkan::states::rebuild = true;
|
ext::vulkan::states::rebuild = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,7 +530,7 @@ void ext::vulkan::tick() {
|
|||||||
auto tasks = uf::thread::schedule( settings::invariant::multithreadedRecording );
|
auto tasks = uf::thread::schedule( settings::invariant::multithreadedRecording );
|
||||||
for ( auto& renderMode : renderModes ) { if ( !renderMode || (renderMode->executed && !renderMode->execute) ) continue;
|
for ( auto& renderMode : renderModes ) { if ( !renderMode || (renderMode->executed && !renderMode->execute) ) continue;
|
||||||
if ( ext::vulkan::states::rebuild || renderMode->rebuild ) tasks.queue([renderMode]{
|
if ( ext::vulkan::states::rebuild || renderMode->rebuild ) tasks.queue([renderMode]{
|
||||||
if ( settings::invariant::individualPipelines ) renderMode->bindPipelines();
|
renderMode->bindPipelines();
|
||||||
renderMode->createCommandBuffers();
|
renderMode->createCommandBuffers();
|
||||||
});
|
});
|
||||||
else if ( renderMode->rerecord ) tasks.queue([renderMode]{
|
else if ( renderMode->rerecord ) tasks.queue([renderMode]{
|
||||||
|
|||||||
@ -44,7 +44,7 @@ void uf::camera::update( pod::Camera& camera, bool override ) {
|
|||||||
#if UF_USE_OPENVR
|
#if UF_USE_OPENVR
|
||||||
if ( this->m_pod.stereoscopic && ext::openvr::context ) {
|
if ( this->m_pod.stereoscopic && ext::openvr::context ) {
|
||||||
camera.transform.orientation = uf::quaternion::identity();
|
camera.transform.orientation = uf::quaternion::identity();
|
||||||
pod::Matrix4t<> view = uf::matrix::inverse( uf::transform::model( camera.transform, false, 1 ) );
|
pod::Matrix4t<> view = uf::matrix::inverse( uf::transform::model( camera.transform ) );
|
||||||
camera.transform.orientation = ext::openvr::hmdQuaternion();
|
camera.transform.orientation = ext::openvr::hmdQuaternion();
|
||||||
|
|
||||||
uf::camera::view( camera, ext::openvr::hmdViewMatrix(vr::Eye_Left, view ), 0 );
|
uf::camera::view( camera, ext::openvr::hmdViewMatrix(vr::Eye_Left, view ), 0 );
|
||||||
@ -52,7 +52,7 @@ void uf::camera::update( pod::Camera& camera, bool override ) {
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
pod::Matrix4t<> view = uf::matrix::inverse( uf::transform::model( camera.transform, false, 1 ) );
|
pod::Matrix4t<> view = uf::matrix::inverse( uf::transform::model( camera.transform ) );
|
||||||
uf::camera::view( camera, view );
|
uf::camera::view( camera, view );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,13 +131,14 @@ void uf::physics::step( pod::World& world, float dt ) {
|
|||||||
if ( uf::physics::settings.warmupSolver ) impl::prepareManifoldCache( uf::physics::settings.manifoldsCache, islands, bodies );
|
if ( uf::physics::settings.warmupSolver ) impl::prepareManifoldCache( uf::physics::settings.manifoldsCache, islands, bodies );
|
||||||
|
|
||||||
// iterate islands
|
// iterate islands
|
||||||
#pragma omp parallel for schedule(dynamic)
|
//#pragma omp parallel for schedule(dynamic)
|
||||||
for ( auto& island : islands ) {
|
auto tasks = uf::thread::schedule(true);
|
||||||
|
for ( auto& island : islands ) tasks.queue([&]{
|
||||||
STATIC_THREAD_LOCAL(uf::stl::vector<pod::Manifold>, manifolds);
|
STATIC_THREAD_LOCAL(uf::stl::vector<pod::Manifold>, manifolds);
|
||||||
manifolds.reserve(uf::physics::settings.reserveCount);
|
manifolds.reserve(uf::physics::settings.reserveCount);
|
||||||
|
|
||||||
// sleeping island, skip (asleep islands shouldn't ever be in here)
|
// sleeping island, skip (asleep islands shouldn't ever be in here)
|
||||||
if ( !island.awake ) continue;
|
if ( !island.awake ) return;
|
||||||
|
|
||||||
// iterate overlap pairs
|
// iterate overlap pairs
|
||||||
for ( auto& [ ia, ib ] : island.pairs ) {
|
for ( auto& [ ia, ib ] : island.pairs ) {
|
||||||
@ -197,7 +198,8 @@ void uf::physics::step( pod::World& world, float dt ) {
|
|||||||
if ( uf::physics::settings.warmupSolver ) {
|
if ( uf::physics::settings.warmupSolver ) {
|
||||||
impl::updateManifoldCache( manifolds, uf::physics::settings.manifoldsCache );
|
impl::updateManifoldCache( manifolds, uf::physics::settings.manifoldsCache );
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
uf::thread::execute( tasks );
|
||||||
|
|
||||||
if ( uf::physics::settings.warmupSolver ) impl::pruneManifoldCache( uf::physics::settings.manifoldsCache );
|
if ( uf::physics::settings.warmupSolver ) impl::pruneManifoldCache( uf::physics::settings.manifoldsCache );
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user