Skip to content

Commit fdc0e55

Browse files
committed
Update source code and contents
1 parent 5662259 commit fdc0e55

File tree

78 files changed

+1491
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1491
-283
lines changed

bookcontents/chapter-03/chapter-03.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,6 @@ public class Device {
341341
try (var stack = MemoryStack.stackPush()) {
342342
PointerBuffer reqExtensions = createReqExtensions(physDevice, stack);
343343

344-
// Set up required features
345-
var features = VkPhysicalDeviceFeatures.calloc(stack);
346-
...
347-
348344
// Enable all the queue families
349345
var queuePropsBuff = physDevice.getVkQueueFamilyProps();
350346
int numQueuesFamilies = queuePropsBuff.capacity();
@@ -360,7 +356,6 @@ public class Device {
360356
var deviceCreateInfo = VkDeviceCreateInfo.calloc(stack)
361357
.sType$Default()
362358
.ppEnabledExtensionNames(reqExtensions)
363-
.pEnabledFeatures(features)
364359
.pQueueCreateInfos(queueCreationInfoBuf);
365360

366361
PointerBuffer pp = stack.mallocPointer(1);
@@ -373,9 +368,7 @@ public class Device {
373368
}
374369
```
375370

376-
The Vulkan structure `VkDevice` is the one that will hold or Vulkan logical device. We will use that structure for the creation of the resources we will need later on. In the constructor we start the familiar try/catch block to allocate short-lived objects in the LWJGL stack and start by allocating the required extension which will be return by the `createReqExtensions` method (we will see this later). After that, we need set the features that we want to use. Features are certain capabilities which can be present or not in your physical device. For the ones that are present we can choose which ones to enable for our logical device. Some features control if compressed textures are enabled or not, if 64 bit floats are supported, etc. We could just simple use the set of features already supported by our physical device but doing this we may affect performance. By now we will not be enabling any feature, so we just allocate an empty structure.
377-
378-
Then we need to enable the queues families that this logical device will use. Later on, when we create queues, we will need to specify the queue family which it belongs to. If that queue family has been not be enabled for the logical device we will get an error. In this case we will opt for enabling all the supported queues families (which is an structure that we obtained while creating the physical device).
371+
The Vulkan structure `VkDevice` is the one that will hold or Vulkan logical device. We will use that structure for the creation of the resources we will need later on. In the constructor we start the familiar try/catch block to allocate short-lived objects in the LWJGL stack and start by allocating the required extension which will be return by the `createReqExtensions` method (we will see this later). Then we need to enable the queues families that this logical device will use. Later on, when we create queues, we will need to specify the queue family which it belongs to. If that queue family has been not be enabled for the logical device we will get an error. In this case we will opt for enabling all the supported queues families (which is an structure that we obtained while creating the physical device).
379372

380373
We basically create a `Buffer` of `VkDeviceQueueCreateInfo` structures which will hold the index of each queue family and its priority. The priority is mechanism that allows us to instruct the driver to prioritize the work submitted by using the priorities assigned to each queue family. However, this is prioritization mechanism is not mandated in the specification. Drivers are free to apply the algorithms they consider in order to balance the work. Therefore, in our case we will just set priorities to a fixed value of `0.0` (which is the default value for the lowest priority, we simply don't care).
381374

bookcontents/chapter-04/chapter-04.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,13 @@ public class ImageView {
273273

274274
private final int aspectMask;
275275
private final int mipLevels;
276+
private final long vkImage;
276277
private final long vkImageView;
277278

278279
public ImageView(Device device, long vkImage, ImageViewData imageViewData) {
279280
this.aspectMask = imageViewData.aspectMask;
280281
this.mipLevels = imageViewData.mipLevels;
282+
this.vkImage = vkImage;
281283
try (var stack = MemoryStack.stackPush()) {
282284
LongBuffer lp = stack.mallocLong(1);
283285
var viewCreateInfo = VkImageViewCreateInfo.calloc(stack)
@@ -344,6 +346,10 @@ public class SwapChain {
344346
KHRSwapchain.vkDestroySwapchainKHR(device.getVkDevice(), vkSwapChain, null);
345347
}
346348

349+
public long getVkImage() {
350+
return vkImage;
351+
}
352+
347353
public ImageView getImageView(int pos) {
348354
return imageViews[pos];
349355
}

0 commit comments

Comments
 (0)