56 class RV_VKCommandBufferAllocator;
63 class RV_StagingBufferPool;
65 #ifdef VULKAN_PRESENTATION
69 class rv_ThreadedRenders;
74 typedef std::pair<VkPipelineStageFlags,VkPipelineStageFlags>
RV_BarrierScope;
94 VkDevice
device() {
return myInst->getDevice(); }
109 void endFrame(
int frame_depth);
138 void resetRenderState();
144 void copyRenderState(
const RenderState*
state);
147 RenderState getRenderState();
160 void resetPipeState();
162 void commitPipeState();
165 void pushPipeState();
175 void setCullMode(
bool enable,
bool back_face =
true,
bool is_ccw =
true);
177 void setLineWidth(
float width);
197 void setDepthBias(
bool enable,
float zconst,
float zslope,
float clamp = 0.
f);
200 bool isDepthBiasEnabled()
const;
207 void setReverseDepth(
bool reverse);
219 void setStencilEnable(
bool enable);
222 bool getStencilEnable()
const;
229 bool set_back =
true);
237 bool set_back =
true);
239 void setStencilBackTest(
244 void setStencilBackOp(
253 void setViewport2DI(
bool enable,
const UT_DimRect &rect);
256 void setScissor2DI(
bool enable,
const UT_DimRect &rect);
263 void setBlendEnable(
bool blend);
313 , myConnectGroup(connect)
315 , myInstanceGroup(inst)
326 , myConnectGroup(connect)
327 , myConnectRange(connect_num)
328 , myInstanceGroup(inst)
346 #define WIP_VULKAN_DEFER_DRAW
347 #ifdef WIP_VULKAN_DEFER_DRAW
349 bool myIsDeferring =
false;
371 #ifdef WIP_VULKAN_DEFER_DRAW
373 "Called while in deferred mode, bound values will likely "
376 return myPushConstants;
428 { myCurOccludeQuery =
q; }
441 void flush(
bool wait_for_finish);
445 bool runCompute(
int wg_x,
int wg_y,
int wg_z);
527 myPostThreadingCallbacks.append(callback);
546 #define WIP_VULKAN_DEFER_BARRIERS
547 #ifdef WIP_VULKAN_DEFER_BARRIERS
598 int myFrameExecBarrierCount = 0;
599 int myFrameMemBarrierCount = 0;
620 int length,
int src_start = 0,
623 #ifdef VULKAN_PRESENTATION
625 void present(RV_VKSwapchain* sc);
634 void privSubmitCB(
bool wait_for_finish);
650 static const int theMaxSets = 8;
651 static constexpr
int theSetSize = 16*theMaxSets;
664 exint myFrameDepth = 0;
665 bool myIsRendering =
false;
666 bool myIsReverseDepth =
false;
673 : myPipeState( r->myPipeStateStack.
last() )
674 , myBoundSets{ r->myBoundSets }
675 , myBoundShader(
r->getShader() )
676 , myBoundFramebuffer(
r->getDrawFramebuffer() )
677 , myIsReverseDepth(
r->isReverseDepth() )
678 , myIsDeferring(
r->myIsDeferring )
696 friend rv_ThreadedRenders;
719 myFrameDepth = myR.beginFrame();
723 myR.endFrame(myFrameDepth);
A collection of Vulkan UBO, SSBO, and Image shader bindings (descriptor set)
RenderState(RV_Render *r)
void drawInstanced(RV_Geometry *geo, int connect_index, int instance_group, const RV_OverrideList *override_list=nullptr)
RV_Framebuffer * myBoundFramebuffer
RAII wrapper for RV_Render beginFrame/EndFrame calls.
RV_VKPipelineStateInfo * getPipelineState()
Return the current pipeline State.
GLenum GLuint GLenum GLsizei const GLchar * buf
bool runCompute(int wg_x, int wg_y, int wg_z)
bool isDeferringDraws() const
RV_PushConstants & getPushConstants()
VkDevice device()
The raw vulkan device.
int getRenderIndex() const
void addBufferBarrier(RV_BarrierScope scope, const VkBufferMemoryBarrier &barrier, RV_VKBuffer *buf)
Add a barrier for buffer synchronization.
void addPostThreadingCallback(const Callback &callback)
RV_ShaderProgram * getGraphicsShader()
void pushShader()
Store the current shader.
UT_UniquePtr< DrawTask > myTask
const UT_Array< RV_AccelStructShaderInfo > & getAccelStructShaderInfos()
RV_ShaderProgramBase * myBoundShader
void executeAllBarriers()
Execute all commands with barriers.
RV_RenderAutoFrame(RV_Render &r)
void pushDrawFramebuffer()
Save the current render framebuffer.
RV_ShaderVariableSet * getSet(int set_num)
Return the bound variable set at index 'set_num'.
void setQuery(RV_OcclusionQuery *q)
Make occlusion query 'q' the active query (only 1 can be active at once)
void draw(RV_Geometry *geo, int connect_index, const RV_OverrideList *override_list=nullptr)
Draw the geometry 'geo' with the given connectivity group.
Object that represents drawable geometry. This object holds vertex, instancing and index buffers for ...
void executeBarriers(RV_StageGroup stages)
Execute all commands on some queues (graphics, compute, transfer).
RV_ShaderProgramBase * getShader()
Get the current shader.
PUGI__FN void reverse(I begin, I end)
GLuint GLsizei GLsizei * length
void drawInstancedRange(RV_Geometry *geo, int connect_index, int connect_num, int inst_group, const RV_OverrideList *override_list=nullptr)
Draw using instancing a range of connectivity groups.
RV_VKAccelerationStructure * getTopLevelAccelStruct() const
std::pair< VkPipelineStageFlags, VkPipelineStageFlags > RV_BarrierScope
RV_VKCommandBuffer::Callback RVmakeDestroyPtrTask(UT_UniquePtr< T > obj)
void flush(bool wait_for_finish)
VkFlags VkPipelineStageFlags
UT_TaskArena & getTaskArena()
GLdouble GLdouble GLdouble q
void unbindSet(int set_num)
Remove a bound variable set by index.
RV_Render * getThreadedRender(int &out_depth, int &out_idx)
void addAccelStruct(RV_VKAccelerationStructure *accel_struct)
DefaultDrawTask(RV_Geometry *geo, int connect, const RV_OverrideList *override_list, int inst=-1)
int getNumCommandBuffers() const
get the number of parallel command buffers within our pool
void clearBarriers()
Remove all currently added barriers.
bool bindSetWithoutUpdate(RV_ShaderVariableSet *set, const RV_ShaderProgramBase *shr)
int getNumRenderThreads() const
Get desired number of threads to use for parallel rendering.
RV_VKCommandBuffer * getCurrentCB()
The currently recording command buffer.
void enableThreadedRender()
int getNDCNearPlane() const
void addDebugBarrier()
Add debug barrier that waits for all previous events.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
void returnThreadedRender(int depth)
#define UT_ASSERT_MSG(ZZ,...)
vint4 blend(const vint4 &a, const vint4 &b, const vbool4 &mask)
bool isThreadedRender() const
check whether this RV_Render is doing a threaded task
bool isInFrame()
Returns true if currently rendering a frame.
std::array< T, N > UT_FixedArray
UT_Array< DrawState > myRecordedDraws
int getNDCFarPlane() const
RV_Render * getMainRender()
UT_UniquePtr< RV_VKAccelerationStructure > RV_VKAccelerationStructurePtr
DefaultDrawTask(RV_Geometry *geo, int connect, int connect_num, const RV_OverrideList *override_list, int inst=-1)
UT_Function< void(RV_Instance *)> Callback
void setShader(RV_ShaderProgramBase *sh)
Set the current shader to 'sh'.
UT_Array< RV_ShaderVariableSet * > mySets
const RV_OcclusionQuery * getQuery() const
Return the currently active occlusion query.
constexpr auto set(type rhs) -> int
bool isMainRender() const
check whether this RV_Render is doing a threaded task
RV_VKPipelineStateInfo myPipelineState
RV_StageGroup RVgetStageGroup(VkPipelineStageFlags stage_bits)
#define SYS_NO_DISCARD_RESULT
GLfloat GLfloat GLfloat alpha
bool copyBuffer(RV_VKBuffer *src, int src_vsize, RV_VKBuffer *dest, int dest_vsize, int length, int src_start=0, int dst_start=0)
std::function< T > UT_Function
bool isReverseDepth() const
Query if reverse depth mapping is enabled.
Handle to the main interface of Vulkan.
bool runComputeIndirect(RV_VKBuffer *buf, exint offset=0)
void bindDrawFramebuffer(RV_Framebuffer *fb)
Make a new framebuffer active.
FS_API bool cleanup(UT_StringArray &removed, UT_StringArray &error_files, exint &memory_freed, bool dry_run, const char *override_path=nullptr)
void popDrawFramebuffer()
Restore the previously pushed framebuffer from pushDrawFramebuffer().
void RVdestroyVKPtr(RV_Render *r, UT_UniquePtr< T > v)
~DefaultDrawTask() override
void addCompletionCallback(const Callback &callback)
GLint GLint GLsizei GLsizei GLsizei depth
RV_Instance * instance()
The instance associated with this render.
__hostdev__ uint64_t last(uint32_t i) const
void popShader()
Restore the previous shader saved by pushShader()
bool isThreading() const
check whether this RV_Render is doing a threaded task
RV_StagingBufferPool * getStagingPool()
RV_Framebuffer * getDrawFramebuffer()
Get the current framebuffer (may be null)
UT_FixedArray< rv_MemoryBarriers, RV_STAGE_NUM > myWaitingBarriers
UT_FixedArray< RV_BarrierScope, RV_STAGE_NUM > myActiveBarriers
RV_ShaderProgram * myShader
void queueDraw(RV_Geometry *geo, int connect, int connect_num, const RV_OverrideList *override_list, int inst=-1)
void addImageBarrier(RV_BarrierScope scope, const VkImageMemoryBarrier &barrier, RV_VKImage *img)
Add a barrier for image synchronization.
const RV_PushConstants & pushConstants() const
void drawRange(RV_Geometry *geo, int connect_index, int connect_num, const RV_OverrideList *override_list=nullptr)
Draw a range of connectivity groups.
virtual bool runDraw(RV_Render *r)=0
RV_OverrideList myOverrides
void beginAccelStructBuild()
void endAccelStructBuild()
RV_ShaderCompute * getComputeShader()
png_structrp int png_fixed_point red
RV_VKPipelineStateInfo myPipeState
UT_SmallArray< RV_ShaderVariableSet *, theSetSize > myBoundSets
bool bindSet(RV_ShaderVariableSet *set, const RV_ShaderProgramBase *shr)
Bind a variable set to the specific shader program.