Skip to content

Commit

Permalink
Use queue family index types.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Jul 21, 2024
1 parent 6607e63 commit 02f86a9
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public interface VulkanImageMemoryBarrierType
*/

@Value.Parameter
int sourceQueueFamilyIndex();
VulkanQueueFamilyIndex sourceQueueFamilyIndex();

/**
* @return The target queue family for a queue family ownership transfer.
*/

@Value.Parameter
int targetQueueFamilyIndex();
VulkanQueueFamilyIndex targetQueueFamilyIndex();

/**
* @return The image affected by this barrier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ private static void transitionImageLayout(
{
final var barrier_builder =
VulkanImageMemoryBarrier.builder()
.setSourceQueueFamilyIndex(-1)
.setTargetQueueFamilyIndex(-1)
.setSourceQueueFamilyIndex(new VulkanQueueFamilyIndex(-1))
.setTargetQueueFamilyIndex(new VulkanQueueFamilyIndex(-1))
.setImage(image)
.setSubresourceRange(
VulkanImageSubresourceRange.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ public static VkImageMemoryBarrier packInto(
.sType(VK10.VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER)
.pNext(0L)
.dstAccessMask(VulkanEnumMaps.packValues(source.targetAccessMask()))
.dstQueueFamilyIndex(source.targetQueueFamilyIndex())
.dstQueueFamilyIndex(source.targetQueueFamilyIndex().value())
.image(checkInstanceOf(source.image(), VulkanLWJGLImage.class).handle())
.newLayout(source.newLayout().value())
.oldLayout(source.oldLayout().value())
.subresourceRange(VulkanLWJGLImageSubresourceRanges.pack(
stack,
source.subresourceRange()))
.srcAccessMask(VulkanEnumMaps.packValues(source.sourceAccessMask()))
.srcQueueFamilyIndex(source.sourceQueueFamilyIndex());
.srcQueueFamilyIndex(source.sourceQueueFamilyIndex().value());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@
import com.io7m.jcoronado.api.VulkanFormatSpace;
import org.junit.jupiter.api.Test;

import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import static com.io7m.jcoronado.api.VulkanFormat.VK_FORMAT_D16_UNORM_S8_UINT;
import static com.io7m.jcoronado.api.VulkanFormat.VK_FORMAT_D24_UNORM_S8_UINT;
import static com.io7m.jcoronado.api.VulkanFormat.VK_FORMAT_D32_SFLOAT_S8_UINT;
import static com.io7m.jcoronado.api.VulkanFormatFeatureFlag.VK_FORMAT_FEATURE_BLIT_DST_BIT;
import static com.io7m.jcoronado.api.VulkanFormatFeatureFlag.VK_FORMAT_FEATURE_BLIT_SRC_BIT;
import static com.io7m.jcoronado.api.VulkanFormatFeatureFlag.VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
import static com.io7m.jcoronado.api.VulkanFormatFeatureFlag.VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
import static com.io7m.jcoronado.api.VulkanFormatFeatureFlag.VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
import static com.io7m.jcoronado.api.VulkanFormatFeatureFlag.VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
import static com.io7m.jcoronado.api.VulkanFormatFeatureFlag.VK_FORMAT_FEATURE_TRANSFER_SRC_BIT;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -236,22 +245,59 @@ public void testSRGB()
}

@Test
public void testShowRenderableBlend()
public void testShowCategorized()
{
final var formats =
new HashSet<>(List.of(VulkanFormat.values()));

for (final var format : VulkanFormat.values()) {
if (format.mandatoryFeatures().contains(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT)) {
System.out.println(format);
final var features =
format.mandatoryFeatures();

if (features.contains(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
&& features.contains(VK_FORMAT_FEATURE_BLIT_DST_BIT)
&& features.contains(VK_FORMAT_FEATURE_BLIT_SRC_BIT)) {
continue;
}

formats.remove(format);
}

System.out.println("Basic:");
for (final var format : formats.stream().sorted(Comparator.comparing(Enum::name)).toList()) {
System.out.printf(" %s%n", format);
}
}

@Test
public void testShowRenderable()
{
for (final var format : VulkanFormat.values()) {
if (format.mandatoryFeatures().contains(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
System.out.println(format);
final var features =
format.mandatoryFeatures();

if (features.contains(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
continue;
}

formats.remove(format);
}

System.out.println("Renderable:");
for (final var format : formats.stream().sorted(Comparator.comparing(Enum::name)).toList()) {
System.out.printf(" %s%n", format);
}

for (final var format : VulkanFormat.values()) {
final var features =
format.mandatoryFeatures();

if (features.contains(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT)) {
continue;
}

formats.remove(format);
}

System.out.println("Blendable:");
for (final var format : formats.stream().sorted(Comparator.comparing(Enum::name)).toList()) {
System.out.printf(" %s%n", format);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.io7m.jcoronado.api.VulkanImageMemoryBarrier;
import com.io7m.jcoronado.api.VulkanImageSubresourceRange;
import com.io7m.jcoronado.api.VulkanIncompatibleClassException;
import com.io7m.jcoronado.api.VulkanQueueFamilyIndex;
import com.io7m.jcoronado.lwjgl.VulkanLWJGLImage;
import com.io7m.jcoronado.lwjgl.VulkanLWJGLImageMemoryBarriers;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -101,8 +102,8 @@ public void testOffsetPack()
EnumSet.allOf(VulkanAccessFlag.class),
VulkanImageLayout.VK_IMAGE_LAYOUT_UNDEFINED,
VulkanImageLayout.VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
23,
25,
new VulkanQueueFamilyIndex(23),
new VulkanQueueFamilyIndex(25),
image,
subresource
);
Expand Down Expand Up @@ -135,8 +136,8 @@ public void testOffsetPackList()
EnumSet.allOf(VulkanAccessFlag.class),
VulkanImageLayout.VK_IMAGE_LAYOUT_UNDEFINED,
VulkanImageLayout.VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
23,
25,
new VulkanQueueFamilyIndex(23),
new VulkanQueueFamilyIndex(25),
image,
subresource
);
Expand Down Expand Up @@ -173,8 +174,8 @@ public void testOffsetPackListOrNull()
EnumSet.allOf(VulkanAccessFlag.class),
VulkanImageLayout.VK_IMAGE_LAYOUT_UNDEFINED,
VulkanImageLayout.VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
23,
25,
new VulkanQueueFamilyIndex(23),
new VulkanQueueFamilyIndex(25),
image,
subresource
);
Expand Down
2 changes: 1 addition & 1 deletion data/formats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ IFS="
"

i=0
for line in $(cat formats.txt)
for line in $(grep -E -v '^#' formats.txt)
do
NAME=$(echo $line | awk -F: '{print $1}')
REST=$(echo $line | sed -E 's/^[A-Z_0-9x]+ : [0-9]+ ://g')
Expand Down
Loading

0 comments on commit 02f86a9

Please sign in to comment.