Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct DrawItemKey
- {
- typedef u64 Type;
- Type key;
- const DrawItem* item;
- };
- class DrawItemSharedResources : NoCreate
- {
- public:
- void Release();
- };
- struct DrawItem
- {
- void Release();
- DrawItemKey::Type GetSortKey() const;
- };
- void SortDrawItemKeys( DrawItemKey* io, DrawItemKey* buffer, u32 count );
- void SortDrawItemKeys( Scope& temp, DrawItemKey* io, u32 count );
- inline void SortDrawItemKeys( Scope& temp, rde::vector<DrawItemKey>& io ) { u32 count = io.size(); if(count) SortDrawItemKeys(temp, &io[0], count); }
- struct LinearDrawDesc
- {
- PrimitiveType::Type primitive;
- u32 primitiveCount;
- u32 vbOffset; // - vbOffset is counting in the number-of-vertices from the start of the buffer, NOT in bytes
- u8 stencilRef;
- bool useStencilRef;
- };
- struct IndexedDrawDesc
- {
- PrimitiveType::Type primitive;
- u32 primitiveCount;
- u32 vbOffset; // - vbOffset is counting in the number-of-vertices from the start of the buffer, NOT in bytes
- u32 ibOffset; // - ibOffset is in number-of-indices, NOT in bytes
- u8 stencilRef;
- bool useStencilRef;
- };
- struct DrawDesc //use one of the above structs instead - they'll be converted to this one
- {
- DrawDesc( const LinearDrawDesc& o )
- : type(internal::DrawCommand::Linear)
- , primitive(o.primitive)
- , primitiveCount(o.primitiveCount)
- , vbOffset(o.vbOffset)
- , stencilRef(o.stencilRef)
- , useStencilRef(o.useStencilRef)
- {}
- DrawDesc( const IndexedDrawDesc& o )
- : type(internal::DrawCommand::Indexed)
- , primitive(o.primitive)
- , primitiveCount(o.primitiveCount)
- , vbOffset(o.vbOffset)
- , ibOffset(o.ibOffset)
- , stencilRef(o.stencilRef)
- , useStencilRef(o.useStencilRef)
- {}
- u32 primitiveCount;
- u32 vbOffset;
- u32 ibOffset;
- u8 stencilRef;
- u8 useStencilRef;
- u8 type;//internal::DrawCommand::Type
- u8 primitive;//PrimitiveType::Type
- };
- struct IndirectDrawDesc
- {
- BufferId buffer;
- u32 offset;//4 byte aligned
- u8 primitive;//PrimitiveType::Type
- u8 linear;//0=indexed draw, 1=linear draw
- u8 stencilRef;
- u8 useStencilRef;
- u32 drawCount; // if >1, multi-draw
- u32 stride; // for multi-draw only. Must be >= offset, 4 byte aligned
- };
- struct AutoDrawDesc
- {
- // input vertex data must be in stream[0], that buffer must have been created with the stream-out flag, and data must have been streamed into it already
- // primitiveCount will be fetched from the buffer's stream-out counter
- u8 primitive;//PrimitiveType::Type
- u8 stencilRef;
- u8 useStencilRef;
- u8 _pad_;
- };
- struct FlattenedDrawStates
- {
- ...
- u8 blob[Size];
- };
- class DrawItemWriter
- {
- public:
- inline DrawItemWriter(){eiDEBUG( m_gpu = 0 );}
- // Either pass a Scope allocator, or pass 'Persistent'.
- // In the Persistent case: Each DrawItem must have it's Release function called, and
- // the DrawItemSharedResources must have it's Release function called.
- // In the Scope case: the DrawItems and DrawItemSharedResource will be released automatically by the supplied Scope. Do not call Release on them.
- void Begin( GpuDevice& gpu, Scope& alloc );
- void Begin( GpuDevice& gpu, Persistent_tag, DrawItemSharedResources* reuseExistingSharedData=0 );
- void BeginPass( u32 passIndex, const PassState* );
- void BeginPass( const RenderPass& );
- void PreFlattenStates( FlattenedDrawStates& output, u32 stateGroupCount, const StateGroup*const* stateGroups );//If you're going to use the same state-group stack for multiple draws within a pass, this lets you pay the stack-flattening cost once.
- DrawItem* Add( const char* name, const DrawDesc&, u32 stateGroupCount, const StateGroup*const* stateGroups, const DrawItemOptions& opt = DrawItemOptions() );
- DrawItem* Add( const char* name, const DrawDesc&, const FlattenedDrawStates&, const DrawItemOptions& opt = DrawItemOptions() );
- DrawItem* Add( const char* name, const IndirectDrawDesc&, u32 stateGroupCount, const StateGroup*const* stateGroups, const DrawItemOptions& opt = DrawItemOptions() );
- DrawItem* Add( const char* name, const IndirectDrawDesc&, const FlattenedDrawStates&, const DrawItemOptions& opt = DrawItemOptions() );
- DrawItem* Add( const char* name, const AutoDrawDesc&, u32 stateGroupCount, const StateGroup*const* stateGroups, const DrawItemOptions& opt = DrawItemOptions() );
- DrawItem* Add( const char* name, const AutoDrawDesc&, const FlattenedDrawStates&, const DrawItemOptions& opt = DrawItemOptions() );
- void EndPass();
- DrawItemSharedResources* End();
- private:
- ...
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement