Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_comparerstage.hpp
Go to the documentation of this file.
1#pragma once
2#include "../core/foray_samplercollection.hpp"
3#include "../foray_glm.hpp"
5#include <array>
6
7namespace foray::stages {
8
11 {
12 public:
14 inline static constexpr std::string_view OutputName = "Comparer.Out";
15
17 virtual void Init(core::Context* context, bool flipY);
18
20 virtual void RecordFrame(VkCommandBuffer cmdBuffer, base::FrameRenderInfo& renderInfo) override;
21
23 virtual void HandleEvent(const osi::Event* event);
24 virtual void Resize(const VkExtent2D& extent) override;
25
26 virtual void Destroy() override;
27
28 enum class EInputType
29 {
30 Float,
31 Int,
32 Uint
33 };
34
36 struct InputInfo
37 {
41 uint32_t ChannelCount = 4;
43 glm::vec4 Scale = glm::vec4(1.f);
45 VkImageAspectFlags Aspect = VkImageAspectFlagBits::VK_IMAGE_ASPECT_COLOR_BIT;
48 };
49
51 {
52 glm::vec4 Value;
53 glm::vec2 UvPos;
54 glm::ivec2 TexelPos;
55 };
56
60 virtual void SetInput(uint32_t index, const InputInfo& input);
61
63 FORAY_PROPERTY_V(MixValue)
65
66 protected:
77
78 void CreateSubStage(SubStage& substage);
79 void DispatchSubStage(SubStage& substage, VkCommandBuffer buffer, base::FrameRenderInfo& renderInfo);
80 void DestroySubStage(SubStage& substage, bool final);
81
83
86
88 {
89 glm::vec4 Scale;
90 glm::ivec2 MousePos;
91 uint32_t Channels;
93 uint32_t WriteOffset;
94 VkBool32 WriteLeft;
95 };
96
97 std::array<SubStage, 2> mSubStages;
98
101 void* mPipetteMap = nullptr;
102
104
105 std::array<core::ShaderModule, 3> mShaders;
106
108 glm::ivec2 mMousePos = {};
109 bool mFlipY = false;
110 };
111} // namespace foray::stages
Context used for render processes. This object is rebuilt for every frame. /.
Definition foray_framerenderinfo.hpp:14
Wraps an image + sampler combination.
Definition foray_samplercollection.hpp:61
Helps with the creation of a VkDescriptorSetLayout and VkDescriptorSet.
Definition foray_descriptorset.hpp:15
Wraps allocation and lifetime functionality of a VkBuffer.
Definition foray_managedbuffer.hpp:12
Wraps allocation and lifetime functionality of VkImage.
Definition foray_managedimage.hpp:13
Wraps shader code driver handle (VkShaderModule). See ShaderManager for compiling shaders dynamically...
Definition foray_shadermodule.hpp:11
Base class for operating system events.
Definition foray_event.hpp:13
Displays two images of any type next to each other, and get a "pipette" readout at the mouse location...
Definition foray_comparerstage.hpp:11
void CreateSubStage(SubStage &substage)
void DispatchSubStage(SubStage &substage, VkCommandBuffer buffer, base::FrameRenderInfo &renderInfo)
PipetteValue mPipetteValue
Definition foray_comparerstage.hpp:103
virtual void Resize(const VkExtent2D &extent) override
Default implementation accesses mImageOutputs and calls ManagedImage::Resize(extent) on any set image...
core::ManagedImage mOutput
Definition foray_comparerstage.hpp:99
static constexpr std::string_view OutputName
Image output name.
Definition foray_comparerstage.hpp:14
virtual void RecordFrame(VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo) override
Pipeline barriers and compute shader dispatches.
std::array< SubStage, 2 > mSubStages
Definition foray_comparerstage.hpp:97
virtual void Destroy() override
Destroy the render stage. Finalizes all components.
bool mFlipY
Definition foray_comparerstage.hpp:109
std::array< core::ShaderModule, 3 > mShaders
Definition foray_comparerstage.hpp:105
core::ManagedBuffer mPipetteBuffer
Definition foray_comparerstage.hpp:100
fp32_t mMixValue
Definition foray_comparerstage.hpp:107
virtual void Init(core::Context *context, bool flipY)
Inits the comparer stage. SetInput() calls afterwards are required for function.
virtual void SetInput(uint32_t index, const InputInfo &input)
Set the input.
virtual void HandleEvent(const osi::Event *event)
If called the comparer stage will filter for MouseMoved events to update the pipette value returned.
void * mPipetteMap
Definition foray_comparerstage.hpp:101
glm::ivec2 mMousePos
Definition foray_comparerstage.hpp:108
void DestroySubStage(SubStage &substage, bool final)
EInputType
Definition foray_comparerstage.hpp:29
Render stage base class giving a common interface for rendering processes.
Definition foray_renderstage.hpp:15
Class that holds memory ownership of a vulkan pipeline layout.
Definition foray_pipelinelayout.hpp:12
#define FORAY_GETTER_CR(member)
Return constant reference.
Definition foray_basics.hpp:60
#define FORAY_PROPERTY_V(member)
Getter+Setter shorthand for value types.
Definition foray_basics.hpp:81
Definition foray_blitstage.hpp:4
float fp32_t
stdint.h style 32 bit floating point type alias (float)
Definition foray_basics.hpp:13
Non owning context object.
Definition foray_context.hpp:16
Argument struct for setting inputs.
Definition foray_comparerstage.hpp:37
glm::vec4 Scale
Scale applied to each channel before writing to output.
Definition foray_comparerstage.hpp:43
core::ManagedImage * Image
Image.
Definition foray_comparerstage.hpp:39
uint32_t ChannelCount
Channels per pixel.
Definition foray_comparerstage.hpp:41
VkImageAspectFlags Aspect
Aspect required for the barrier to function.
Definition foray_comparerstage.hpp:45
EInputType Type
Channel type (required to select correct shader input)
Definition foray_comparerstage.hpp:47
Definition foray_comparerstage.hpp:51
glm::ivec2 TexelPos
Definition foray_comparerstage.hpp:54
glm::vec2 UvPos
Definition foray_comparerstage.hpp:53
glm::vec4 Value
Definition foray_comparerstage.hpp:52
Definition foray_comparerstage.hpp:88
uint32_t Channels
Definition foray_comparerstage.hpp:91
glm::ivec2 MousePos
Definition foray_comparerstage.hpp:90
glm::vec4 Scale
Definition foray_comparerstage.hpp:89
VkBool32 WriteLeft
Definition foray_comparerstage.hpp:94
fp32_t Mix
Definition foray_comparerstage.hpp:92
uint32_t WriteOffset
Definition foray_comparerstage.hpp:93
Value between 0...1 defining the split value.
Definition foray_comparerstage.hpp:68
util::PipelineLayout PipelineLayout
Definition foray_comparerstage.hpp:74
VkPipeline Pipeline
Definition foray_comparerstage.hpp:75
core::DescriptorSet DescriptorSet
Definition foray_comparerstage.hpp:73
InputInfo Input
Definition foray_comparerstage.hpp:70
core::CombinedImageSampler InputSampled
Definition foray_comparerstage.hpp:71
uint32_t Index
Definition foray_comparerstage.hpp:69
core::ShaderModule * Shader
Definition foray_comparerstage.hpp:72