From another thread:
[QUOTE=Salabar;37645]That’s how I see this.
Lesson 1:
Goal: to understand a general framework of Vulkan. It’s alright to use vkFinish-like functions and not explain them in depth, since it is not really important for now. Helper functions will be used for context initialization and shader compilation.
Initialize Vulkan runtime and a GPU.
Create a compute queue, allocate a memory page in Host-accessible device memory. Create a shader that fills a buffer with thread_ids.
Create a huge command buffer which will make all of manipulations required in this sample.
Dispatch it.
Map the buffer into host memory, printf it.
Clean up job.
Homework: alter the shader in such way it writes thread_id squared instead.[/quote]
Hmm. If I’m a beginning graphics programmer, and the first chapter I read doesn’t involve making something even remotely like a picture, with some form of color on it, I might be put off. At the very least, it should produce some kind of picture that can be viewed. Ideally, it would draw to an actual window.
I don’t think that it would be too much to make it deliver colors rather than thread_ids. The colors could be derived from the “thread_id”. This could be done via a table in the shader that converts (truncated) IDs to colors. This would also help get the programmer used to the idea that shader code writing isn’t that much different from non-shader writing, since a constant array is something that they should be familiar with from C/C++.
Yes, images are a bit more complex (using Mantle as a guide). But that’s mainly due to uploading; simply allocating memory and assigning it to an image isn’t that difficult. Without the uploading process, it could be pretty rudimentary.
Also, this would give the user more room to play around with, in terms of what they can change and modify. They can play with different colors and see the results.
The downside to this whole apporach (one I didn’t realize before), is that to do what you’ve suggested, you have to deal with descriptor sets/layouts. Since that’s how you’re writing your output data, whether an image or a buffer, there still has to be at least a cursory examination of this concept. That’s still quite a lot for them to deal with. Not as much as doing the full rendering pipeline, but it’s still there.
[QUOTE=Salabar;37645]Lesson 2:
Goal: In depth explanation on how resource attachment works.
Create a shader:
DrawEllipse(int4 offset_and_radiuses, int3 color, int3_buffer output_image){
if point (thread_id.x, thread_id.y) is in ellipse (offset_and_radiuses)
output_image[thread_id] = color;
}
Final application will let user to type indefinite number of circles to draw. After each draw, it maps the resulting image into host memory and saves it into BMP or another elementary image format.
Homework: create a shader for drawing of rectangles, learn to switch between different shaders.[/quote]
Lesson 1 covered resource attachment already, since you needed that to write data. This would be covering reading data from the shader, which also necessitates the ability for the user to write such data.
[QUOTE=Salabar;37645]Lesson 3:
In depth synchronization.
Move image buffer into unmappable area. Explain why it is important.
Create another queue. Use it to issue DMA mechanism instead of mapping as in previous lesson.
Use fences so DMA-queue stalls until draw-queue in done drawing and vice-versa. Explain why explicit synch is bad.
Homework:
Remove all vkFinish calls using fences.
Play with different heaps, try using fences to test the application perfomance when different memory areas are used.[/quote]
I’d suggest focusing instead on multiple Compute operations, chaning into one another. That would segue much better into a discussion of the rendering pipeline. For example if Lesson 2 was about drawing some number of circles based on input buffers, make Lesson 3 creating those input buffers, then executing the lesson 2 operation on it.
That would require talking a lot about synchronization, changing compute shaders, and the like. You could even introduce atomic counters if Vulkan has such things.