VulkanRaytracingCycles 0.0.0
Cycles Render Engine With VulkanRaytracingShaderModules. ( Experiment , in progress)
ImmidiateCmdPool Struct Reference

#include <CmdPoolVk.h>

Public Member Functions

void createCommandPool ()
 
void destroyCommandPool ()
 
void alloc ()
 
void free ()
 
bool allocStaging (size_t size)
 
template<class INFO >
bool allocStaging (INFO &_)
 
void freeStaging ()
 
void begin ()
 
void end ()
 
void submit (int i=0)
 
void wait ()
 

Public Attributes

struct {
   VkDeviceMemory   memory
 
   VkBuffer   buffer
 
   uint8_t *   data
 
   int   Nums
 
   VkMemoryAllocateInfo   allocInfo
 
   VkMemoryRequirements   memReqs
 
   VkBufferCreateInfo   bufferCreateInfo
 
staging = { VK_NULL_HANDLE ,VK_NULL_HANDLE ,nullptr ,0,{}, {},{} }
 
VkCommandBuffer cmd
 
bool commit
 
VkCommandPool cmdPool
 
VkQueue queue
 

Detailed Description

Definition at line 16 of file CmdPoolVk.h.

Inheritance diagram for ImmidiateCmdPool:
ImmidiateCmdPool2 ImmidiateCmdPool3

Member Function Documentation

◆ alloc()

void ImmidiateCmdPool::alloc ( )

Definition at line 92 of file CmdPoolVk.cpp.

92 {
93
95 VkCommandBufferAllocateInfo cmdBufAllocateInfo = vka::plysm::commandBufferAllocateInfo(cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, 1);
96 VK_CHECK_RESULT(vkAllocateCommandBuffers($device, &cmdBufAllocateInfo, &cmd));
97 log_imcm("IMCM queue %x pool %x cmd %x \n ", queue, cmdPool, cmd);
98
99};
#define log_imcm(...)
Definition: CmdPoolVk.h:12
VkCommandBuffer cmd
Definition: CmdPoolVk.h:31
void createCommandPool()
Definition: CmdPoolVk.cpp:252
VkQueue queue
Definition: CmdPoolVk.h:34
VkCommandPool cmdPool
Definition: CmdPoolVk.h:33

◆ allocStaging() [1/2]

template<class INFO >
bool ImmidiateCmdPool::allocStaging ( INFO &  _)
inline

Definition at line 47 of file CmdPoolVk.h.

47 {
48 return allocStaging(_.size);
49 }
bool allocStaging(size_t size)
Definition: CmdPoolVk.cpp:122

◆ allocStaging() [2/2]

bool ImmidiateCmdPool::allocStaging ( size_t  size)

staging.memReqs.memoryTypeBits = 1665; staging.allocInfo.memoryTypeIndex = vka::shelve::getMemoryType(staging.memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);

if (staging.allocInfo.allocationSize < staging.memReqs.size) {

if (staging.allocInfo.allocationSize != 0) {

Definition at line 122 of file CmdPoolVk.cpp.

122 {
123 if (staging.Nums == 0) {
124
125 staging.allocInfo = vka::plysm::memoryAllocateInfo();
126 staging.bufferCreateInfo = vka::plysm::bufferCreateInfo();
127 staging.bufferCreateInfo.size = 0;
128 staging.bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
129 staging.bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
130
133 staging.allocInfo.allocationSize = 0;
134
135 }
136 else log_img("Bridge Test ==>> NUMS == %d \n", staging.Nums);
137 staging.Nums++;
138 if (staging.bufferCreateInfo.size < size) {
139
140 if (staging.bufferCreateInfo.size != 0) {
141 log_img("Bridge Test ==>> destroy stagingBuffer %p \n", staging.buffer);
142 vkDestroyBuffer($device, staging.buffer, nullptr);
143 }
144 staging.bufferCreateInfo.size = size;
145 VK_CHECK_RESULT(vkCreateBuffer($device, &staging.bufferCreateInfo, nullptr, &staging.buffer));
146 vkGetBufferMemoryRequirements($device, staging.buffer, &staging.memReqs);
147 staging.allocInfo.memoryTypeIndex = vka::shelve::getMemoryType(staging.memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, nullptr);
148 log_img("Bridge Test ==>> recreate stagingBuffer %zu %p TypeBits %u TypeIndex %u \n", staging.bufferCreateInfo.size, staging.buffer, (uint32_t)staging.memReqs.memoryTypeBits, (uint32_t)staging.allocInfo.memoryTypeIndex);
149
152
153 if (staging.allocInfo.allocationSize != 0) {
154 log_img("Bridge Test ==>> Free stagingMemory %p \n", staging.memory);
155 vkFreeMemory($device, staging.memory, nullptr);
156 }
157 staging.allocInfo.allocationSize = staging.memReqs.size;
158 VK_CHECK_RESULT(vkAllocateMemory($device, &staging.allocInfo, nullptr, &staging.memory));
159 VK_CHECK_RESULT(vkBindBufferMemory($device, staging.buffer, staging.memory, 0));
160 log_img("Bridge Test ==>> reallocate stagingMemory %zu %p \n", staging.memReqs.size, staging.memory);
161 }
162
163 return true;
164};
#define log_img(...)
Definition: ImagesVk.h:14
struct ImmidiateCmdPool::@11 staging

◆ begin()

void ImmidiateCmdPool::begin ( )

Definition at line 183 of file CmdPoolVk.cpp.

183 {
184 static VkCommandBufferBeginInfo cmdBufInfo = vka::plysm::commandBufferBeginInfo();
185
186 log_imcm("IMCM queue BEGIN %x pool %x cmd %x \n ", queue, cmdPool, cmd);
187 VK_CHECK_RESULT(vkBeginCommandBuffer(cmd, &cmdBufInfo));
188 commit = true;
189};

◆ createCommandPool()

void ImmidiateCmdPool::createCommandPool ( )

queue = ctx->device.Qvillage.queueTR;

Definition at line 252 of file CmdPoolVk.cpp.

253{
254
255
256 ContextVk* ctx = nullptr;
257
258 if (!$tank.takeout(ctx, 0)) {
259 log_bad(" not found ContextVk.");
260 };
261
263 static uint32_t qid = 0;
264 queue = ctx->device.Qvillage.queues[qid];
265 qid = (qid + 1) % 4;
266
267 VkCommandPoolCreateInfo cmdPoolInfo = {};
268 cmdPoolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
269 cmdPoolInfo.queueFamilyIndex = ctx->device.Qvillage.index[0];
270 cmdPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
271 VK_CHECK_RESULT(vkCreateCommandPool($device, &cmdPoolInfo, nullptr, &cmdPool));
272
273};
#define log_bad(...)
Definition: log.hpp:37
struct Context0Vk ContextVk
#define ctx

◆ destroyCommandPool()

void ImmidiateCmdPool::destroyCommandPool ( )

Definition at line 275 of file CmdPoolVk.cpp.

275 {
276 if (cmdPool != VK_NULL_HANDLE) {
277 vkDestroyCommandPool($device, cmdPool, nullptr);
278 cmdPool = VK_NULL_HANDLE;
279 }
280};

◆ end()

void ImmidiateCmdPool::end ( )

Definition at line 191 of file CmdPoolVk.cpp.

191 {
192
193 VK_CHECK_RESULT(vkEndCommandBuffer(cmd));
194 log_img("IMCM Make CopyAfterX %x \n ", cmd);
195
196};

◆ free()

void ImmidiateCmdPool::free ( )

Definition at line 106 of file CmdPoolVk.cpp.

106 {
107 freeStaging();
108 if (cmd != VK_NULL_HANDLE) {
109 log_imcm("dealloc Immidiate %p \n", cmd);
110 vkFreeCommandBuffers($device, cmdPool, 1, &cmd); cmd = VK_NULL_HANDLE;
111 }
113};
void destroyCommandPool()
Definition: CmdPoolVk.cpp:275

◆ freeStaging()

void ImmidiateCmdPool::freeStaging ( )

Definition at line 165 of file CmdPoolVk.cpp.

165 {
166
167 if (staging.buffer != VK_NULL_HANDLE) {
168
169 vkDestroyBuffer($device, staging.buffer, nullptr);
170
171 }
172
173 if (staging.memory != VK_NULL_HANDLE) {
174 vkFreeMemory($device, staging.memory, nullptr);
175
176 }
177
178 staging = { VK_NULL_HANDLE ,VK_NULL_HANDLE ,nullptr };
179
180};

◆ submit()

void ImmidiateCmdPool::submit ( int  i = 0)

log_imcm("IMCM QUEUE submit [%x] %p \n", _threadid, queue);

Definition at line 198 of file CmdPoolVk.cpp.

198 {
199
200 VkSubmitInfo submitInfo = vka::plysm::submitInfo();
201 submitInfo.commandBufferCount = 1;
202 submitInfo.pCommandBuffers = &cmd;
203
204 VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
205
207
208};

◆ wait()

void ImmidiateCmdPool::wait ( )

log_img("IMCM Q Submit %x this[%u] \n ", queue, GetCurrentThreadId());

Definition at line 244 of file CmdPoolVk.cpp.

244 {
245
247 VK_CHECK_RESULT(vkQueueWaitIdle(queue));
248
249 commit = false;
250}

Member Data Documentation

◆ allocInfo

VkMemoryAllocateInfo ImmidiateCmdPool::allocInfo

Definition at line 25 of file CmdPoolVk.h.

◆ buffer

VkBuffer ImmidiateCmdPool::buffer

Definition at line 22 of file CmdPoolVk.h.

◆ bufferCreateInfo

VkBufferCreateInfo ImmidiateCmdPool::bufferCreateInfo

Definition at line 27 of file CmdPoolVk.h.

◆ cmd

VkCommandBuffer ImmidiateCmdPool::cmd

Definition at line 31 of file CmdPoolVk.h.

◆ cmdPool

VkCommandPool ImmidiateCmdPool::cmdPool

Definition at line 33 of file CmdPoolVk.h.

◆ commit

bool ImmidiateCmdPool::commit

Definition at line 32 of file CmdPoolVk.h.

◆ data

uint8_t* ImmidiateCmdPool::data

Definition at line 23 of file CmdPoolVk.h.

◆ memory

VkDeviceMemory ImmidiateCmdPool::memory

Definition at line 21 of file CmdPoolVk.h.

◆ memReqs

VkMemoryRequirements ImmidiateCmdPool::memReqs

Definition at line 26 of file CmdPoolVk.h.

◆ Nums

int ImmidiateCmdPool::Nums
mutable

Definition at line 24 of file CmdPoolVk.h.

◆ queue

VkQueue ImmidiateCmdPool::queue

Definition at line 34 of file CmdPoolVk.h.

◆ 

struct { ... } ImmidiateCmdPool::staging

The documentation for this struct was generated from the following files: