Skip to content

Commit 79b579a

Browse files
committed
Vulkan add support for more vk structs
1 parent 88dc10c commit 79b579a

26 files changed

+770
-82
lines changed

graphics-by-opengl-j2se/src/main/java/com/nucleus/vulkan/Vulkan10.java

+326-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,86 @@
22

33
public interface Vulkan10 {
44

5+
public enum Result {
6+
VK_SUCCESS(0),
7+
VK_NOT_READY(1),
8+
VK_TIMEOUT(2),
9+
VK_EVENT_SET(3),
10+
VK_EVENT_RESET(4),
11+
VK_INCOMPLETE(5),
12+
VK_ERROR_OUT_OF_HOST_MEMORY(-1),
13+
VK_ERROR_OUT_OF_DEVICE_MEMORY(-2),
14+
VK_VK_ERROR_INITIALIZATION_FAILED(-3),
15+
VK_ERROR_DEVICE_LOST(-4),
16+
VK_ERROR_MEMORY_MAP_FAILED(-5),
17+
VK_ERROR_LAYER_NOT_PRESENT(-6),
18+
VK_ERROR_EXTENSION_NOT_PRESENT(-7),
19+
VK_ERROR_FEATURE_NOT_PRESENT(-8),
20+
VK_ERROR_INCOMPATIBLE_DRIVER(-9),
21+
VK_ERROR_TOO_MANY_OBJECTS(-10),
22+
VK_ERROR_FORMAT_NOT_SUPPORTED(-11),
23+
VK_ERROR_FRAGMENTED_POOL(-12),
24+
VK_ERROR_OUT_OF_POOL_MEMORY(-1000069000),
25+
VK_ERROR_INVALID_EXTERNAL_HANDLE(-1000072003),
26+
VK_ERROR_SURFACE_LOST_KHR(-1000000000),
27+
VK_ERROR_NATIVE_WINDOW_IN_USE_KHR(-1000000001),
28+
VK_SUBOPTIMAL_KHR(1000001003),
29+
VK_ERROR_OUT_OF_DATE_KHR(-1000001004),
30+
VK_ERROR_INCOMPATIBLE_DISPLAY_KHR(-1000003001),
31+
VK_ERROR_VALIDATION_FAILED_EXT(-1000011001),
32+
VK_ERROR_INVALID_SHADER_NV(-1000012000),
33+
VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT(-1000158000),
34+
VK_ERROR_FRAGMENTATION_EXT(-1000161000),
35+
VK_ERROR_NOT_PERMITTED_EXT(-1000174001),
36+
VK_ERROR_INVALID_DEVICE_ADDRESS_EXT(-1000244000),
37+
VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT(-1000255000),
38+
VK_ERROR_OUT_OF_POOL_MEMORY_KHR(VK_ERROR_OUT_OF_POOL_MEMORY.value),
39+
VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR(VK_ERROR_INVALID_EXTERNAL_HANDLE.value),
40+
VK_RESULT_MAX_ENUM(0x7FFFFFFF);
41+
42+
public final int value;
43+
44+
private Result(int value) {
45+
this.value = value;
46+
}
47+
48+
public static Result getResult(int value) {
49+
for (Result r : values()) {
50+
if (r.value == value) {
51+
return r;
52+
}
53+
}
54+
return null;
55+
}
56+
57+
}
58+
59+
public enum ShaderStageFlagBits {
60+
VK_SHADER_STAGE_VERTEX_BIT(0x00000001),
61+
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT(0x00000002),
62+
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT(0x00000004),
63+
VK_SHADER_STAGE_GEOMETRY_BIT(0x00000008),
64+
VK_SHADER_STAGE_FRAGMENT_BIT(0x00000010),
65+
VK_SHADER_STAGE_COMPUTE_BIT(0x00000020),
66+
VK_SHADER_STAGE_ALL_GRAPHICS(0x0000001F),
67+
VK_SHADER_STAGE_ALL(0x7FFFFFFF),
68+
VK_SHADER_STAGE_RAYGEN_BIT_NV(0x00000100),
69+
VK_SHADER_STAGE_ANY_HIT_BIT_NV(0x00000200),
70+
VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV(0x00000400),
71+
VK_SHADER_STAGE_MISS_BIT_NV(0x00000800),
72+
VK_SHADER_STAGE_INTERSECTION_BIT_NV(0x00001000),
73+
VK_SHADER_STAGE_CALLABLE_BIT_NV(0x00002000),
74+
VK_SHADER_STAGE_TASK_BIT_NV(0x00000040),
75+
VK_SHADER_STAGE_MESH_BIT_NV(0x00000080),
76+
VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM(0x7FFFFFFF);
77+
78+
public final int value;
79+
80+
private ShaderStageFlagBits(int value) {
81+
this.value = value;
82+
}
83+
}
84+
585
public static class ComponentMapping {
686
public ComponentSwizzle r = ComponentSwizzle.VK_COMPONENT_SWIZZLE_R;
787
public ComponentSwizzle g = ComponentSwizzle.VK_COMPONENT_SWIZZLE_G;
@@ -328,7 +408,6 @@ public enum Format {
328408
VK_FORMAT_ASTC_12x10_SRGB_BLOCK(182),
329409
VK_FORMAT_ASTC_12x12_UNORM_BLOCK(183),
330410
VK_FORMAT_ASTC_12x12_SRGB_BLOCK(184);
331-
332411
public final int value;
333412

334413
private Format(int value) {
@@ -365,7 +444,6 @@ public enum ColorSpaceKHR {
365444
VK_COLOR_SPACE_DISPLAY_NATIVE_AMD(1000213000),
366445
VK_COLORSPACE_SRGB_NONLINEAR_KHR(VK_COLOR_SPACE_SRGB_NONLINEAR_KHR.value),
367446
VK_COLOR_SPACE_DCI_P3_LINEAR_EXT(VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT.value);
368-
369447
public final int value;
370448

371449
private ColorSpaceKHR(int value) {
@@ -383,6 +461,252 @@ public static ColorSpaceKHR get(int value) {
383461

384462
};
385463

464+
public enum PrimitiveTopology {
465+
VK_PRIMITIVE_TOPOLOGY_POINT_LIST(0),
466+
VK_PRIMITIVE_TOPOLOGY_LINE_LIST(1),
467+
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP(2),
468+
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST(3),
469+
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP(4),
470+
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN(5),
471+
VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY(6),
472+
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY(7),
473+
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY(8),
474+
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY(9),
475+
VK_PRIMITIVE_TOPOLOGY_PATCH_LIST(10),
476+
VK_PRIMITIVE_TOPOLOGY_MAX_ENUM(0x7FFFFFFF);
477+
public final int value;
478+
479+
private PrimitiveTopology(int value) {
480+
this.value = value;
481+
}
482+
483+
};
484+
485+
public enum PipelineCreateFlagBits {
486+
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT(0x00000001),
487+
VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT(0x00000002),
488+
VK_PIPELINE_CREATE_DERIVATIVE_BIT(0x00000004),
489+
VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT(0x00000008),
490+
VK_PIPELINE_CREATE_DISPATCH_BASE_BIT(0x00000010),
491+
VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV(0x00000020),
492+
VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR(0x00000040),
493+
VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR(0x00000080),
494+
VK_PIPELINE_CREATE_DISPATCH_BASE(VK_PIPELINE_CREATE_DISPATCH_BASE_BIT.value),
495+
VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR(
496+
VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT.value),
497+
VK_PIPELINE_CREATE_DISPATCH_BASE_KHR(VK_PIPELINE_CREATE_DISPATCH_BASE.value),
498+
VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM(0x7FFFFFFF);
499+
public final int value;
500+
501+
private PipelineCreateFlagBits(int value) {
502+
this.value = value;
503+
}
504+
505+
public static int getMask(PipelineCreateFlagBits[] bits) {
506+
int mask = 0;
507+
for (PipelineCreateFlagBits flag : bits) {
508+
mask += flag.value;
509+
}
510+
return mask;
511+
}
512+
}
513+
514+
public enum PolygonMode {
515+
VK_POLYGON_MODE_FILL(0),
516+
VK_POLYGON_MODE_LINE(1),
517+
VK_POLYGON_MODE_POINT(2),
518+
VK_POLYGON_MODE_FILL_RECTANGLE_NV(1000153000),
519+
VK_POLYGON_MODE_MAX_ENUM(0x7FFFFFFF);
520+
public final int value;
521+
522+
private PolygonMode(int value) {
523+
this.value = value;
524+
}
525+
}
526+
527+
public enum CullModeFlagBits {
528+
VK_CULL_MODE_NONE(0),
529+
VK_CULL_MODE_FRONT_BIT(0x00000001),
530+
VK_CULL_MODE_BACK_BIT(0x00000002),
531+
VK_CULL_MODE_FRONT_AND_BACK(0x00000003),
532+
VK_CULL_MODE_FLAG_BITS_MAX_ENUM(0x7FFFFFFF);
533+
public final int value;
534+
535+
private CullModeFlagBits(int value) {
536+
this.value = value;
537+
}
538+
}
539+
540+
public enum FrontFace {
541+
VK_FRONT_FACE_COUNTER_CLOCKWISE(0),
542+
VK_FRONT_FACE_CLOCKWISE(1),
543+
VK_FRONT_FACE_MAX_ENUM(0x7FFFFFFF);
544+
public final int value;
545+
546+
private FrontFace(int value) {
547+
this.value = value;
548+
}
549+
}
550+
551+
public enum SampleCountFlagBits {
552+
VK_SAMPLE_COUNT_1_BIT(0x00000001),
553+
VK_SAMPLE_COUNT_2_BIT(0x00000002),
554+
VK_SAMPLE_COUNT_4_BIT(0x00000004),
555+
VK_SAMPLE_COUNT_8_BIT(0x00000008),
556+
VK_SAMPLE_COUNT_16_BIT(0x00000010),
557+
VK_SAMPLE_COUNT_32_BIT(0x00000020),
558+
VK_SAMPLE_COUNT_64_BIT(0x00000040),
559+
VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM(0x7FFFFFFF);
560+
public final int value;
561+
562+
private SampleCountFlagBits(int value) {
563+
this.value = value;
564+
}
565+
}
566+
567+
public enum CompareOp {
568+
VK_COMPARE_OP_NEVER(0),
569+
VK_COMPARE_OP_LESS(1),
570+
VK_COMPARE_OP_EQUAL(2),
571+
VK_COMPARE_OP_LESS_OR_EQUAL(3),
572+
VK_COMPARE_OP_GREATER(4),
573+
VK_COMPARE_OP_NOT_EQUAL(5),
574+
VK_COMPARE_OP_GREATER_OR_EQUAL(6),
575+
VK_COMPARE_OP_ALWAYS(7),
576+
VK_COMPARE_OP_MAX_ENUM(0x7FFFFFFF);
577+
public final int value;
578+
579+
private CompareOp(int value) {
580+
this.value = value;
581+
}
582+
}
583+
584+
public enum LogicOp {
585+
VK_LOGIC_OP_CLEAR(0),
586+
VK_LOGIC_OP_AND(1),
587+
VK_LOGIC_OP_AND_REVERSE(2),
588+
VK_LOGIC_OP_COPY(3),
589+
VK_LOGIC_OP_AND_INVERTED(4),
590+
VK_LOGIC_OP_NO_OP(5),
591+
VK_LOGIC_OP_XOR(6),
592+
VK_LOGIC_OP_OR(7),
593+
VK_LOGIC_OP_NOR(8),
594+
VK_LOGIC_OP_EQUIVALENT(9),
595+
VK_LOGIC_OP_INVERT(10),
596+
VK_LOGIC_OP_OR_REVERSE(11),
597+
VK_LOGIC_OP_COPY_INVERTED(12),
598+
VK_LOGIC_OP_OR_INVERTED(13),
599+
VK_LOGIC_OP_NAND(14),
600+
VK_LOGIC_OP_SET(15),
601+
VK_LOGIC_OP_MAX_ENUM(0x7FFFFFFF);
602+
public final int value;
603+
604+
private LogicOp(int value) {
605+
this.value = value;
606+
}
607+
}
608+
609+
public enum BlendOp {
610+
VK_BLEND_OP_ADD(0),
611+
VK_BLEND_OP_SUBTRACT(1),
612+
VK_BLEND_OP_REVERSE_SUBTRACT(2),
613+
VK_BLEND_OP_MIN(3),
614+
VK_BLEND_OP_MAX(4),
615+
VK_BLEND_OP_ZERO_EXT(1000148000),
616+
VK_BLEND_OP_SRC_EXT(1000148001),
617+
VK_BLEND_OP_DST_EXT(1000148002),
618+
VK_BLEND_OP_SRC_OVER_EXT(1000148003),
619+
VK_BLEND_OP_DST_OVER_EXT(1000148004),
620+
VK_BLEND_OP_SRC_IN_EXT(1000148005),
621+
VK_BLEND_OP_DST_IN_EXT(1000148006),
622+
VK_BLEND_OP_SRC_OUT_EXT(1000148007),
623+
VK_BLEND_OP_DST_OUT_EXT(1000148008),
624+
VK_BLEND_OP_SRC_ATOP_EXT(1000148009),
625+
VK_BLEND_OP_DST_ATOP_EXT(1000148010),
626+
VK_BLEND_OP_XOR_EXT(1000148011),
627+
VK_BLEND_OP_MULTIPLY_EXT(1000148012),
628+
VK_BLEND_OP_SCREEN_EXT(1000148013),
629+
VK_BLEND_OP_OVERLAY_EXT(1000148014),
630+
VK_BLEND_OP_DARKEN_EXT(1000148015),
631+
VK_BLEND_OP_LIGHTEN_EXT(1000148016),
632+
VK_BLEND_OP_COLORDODGE_EXT(1000148017),
633+
VK_BLEND_OP_COLORBURN_EXT(1000148018),
634+
VK_BLEND_OP_HARDLIGHT_EXT(1000148019),
635+
VK_BLEND_OP_SOFTLIGHT_EXT(1000148020),
636+
VK_BLEND_OP_DIFFERENCE_EXT(1000148021),
637+
VK_BLEND_OP_EXCLUSION_EXT(1000148022),
638+
VK_BLEND_OP_INVERT_EXT(1000148023),
639+
VK_BLEND_OP_INVERT_RGB_EXT(1000148024),
640+
VK_BLEND_OP_LINEARDODGE_EXT(1000148025),
641+
VK_BLEND_OP_LINEARBURN_EXT(1000148026),
642+
VK_BLEND_OP_VIVIDLIGHT_EXT(1000148027),
643+
VK_BLEND_OP_LINEARLIGHT_EXT(1000148028),
644+
VK_BLEND_OP_PINLIGHT_EXT(1000148029),
645+
VK_BLEND_OP_HARDMIX_EXT(1000148030),
646+
VK_BLEND_OP_HSL_HUE_EXT(1000148031),
647+
VK_BLEND_OP_HSL_SATURATION_EXT(1000148032),
648+
VK_BLEND_OP_HSL_COLOR_EXT(1000148033),
649+
VK_BLEND_OP_HSL_LUMINOSITY_EXT(1000148034),
650+
VK_BLEND_OP_PLUS_EXT(1000148035),
651+
VK_BLEND_OP_PLUS_CLAMPED_EXT(1000148036),
652+
VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT(1000148037),
653+
VK_BLEND_OP_PLUS_DARKER_EXT(1000148038),
654+
VK_BLEND_OP_MINUS_EXT(1000148039),
655+
VK_BLEND_OP_MINUS_CLAMPED_EXT(1000148040),
656+
VK_BLEND_OP_CONTRAST_EXT(1000148041),
657+
VK_BLEND_OP_INVERT_OVG_EXT(1000148042),
658+
VK_BLEND_OP_RED_EXT(1000148043),
659+
VK_BLEND_OP_GREEN_EXT(1000148044),
660+
VK_BLEND_OP_BLUE_EXT(1000148045),
661+
VK_BLEND_OP_MAX_ENUM(0x7FFFFFFF);
662+
public final int value;
663+
664+
private BlendOp(int value) {
665+
this.value = value;
666+
}
667+
}
668+
669+
public enum BlendFactor {
670+
VK_BLEND_FACTOR_ZERO(0),
671+
VK_BLEND_FACTOR_ONE(1),
672+
VK_BLEND_FACTOR_SRC_COLOR(2),
673+
VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR(3),
674+
VK_BLEND_FACTOR_DST_COLOR(4),
675+
VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR(5),
676+
VK_BLEND_FACTOR_SRC_ALPHA(6),
677+
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA(7),
678+
VK_BLEND_FACTOR_DST_ALPHA(8),
679+
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA(9),
680+
VK_BLEND_FACTOR_CONSTANT_COLOR(10),
681+
VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR(11),
682+
VK_BLEND_FACTOR_CONSTANT_ALPHA(12),
683+
VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA(13),
684+
VK_BLEND_FACTOR_SRC_ALPHA_SATURATE(14),
685+
VK_BLEND_FACTOR_SRC1_COLOR(15),
686+
VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR(16),
687+
VK_BLEND_FACTOR_SRC1_ALPHA(17),
688+
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA(18),
689+
VK_BLEND_FACTOR_MAX_ENUM(0x7FFFFFFF);
690+
public final int value;
691+
692+
private BlendFactor(int value) {
693+
this.value = value;
694+
}
695+
}
696+
697+
public enum ColorComponentFlagBits {
698+
VK_COLOR_COMPONENT_R_BIT(0x00000001),
699+
VK_COLOR_COMPONENT_G_BIT(0x00000002),
700+
VK_COLOR_COMPONENT_B_BIT(0x00000004),
701+
VK_COLOR_COMPONENT_A_BIT(0x00000008),
702+
VK_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM(0x7FFFFFFF);
703+
public final int value;
704+
705+
private ColorComponentFlagBits(int value) {
706+
this.value = value;
707+
}
708+
}
709+
386710
public enum Extensions {
387711
VK_KHR_16bit_storage(),
388712
VK_KHR_8bit_storage(),

graphics-by-opengl-j2se/src/main/java/com/nucleus/vulkan/Vulkan10Wrapper.java

+11
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@
77
import com.nucleus.vulkan.Vulkan10.ColorSpaceKHR;
88
import com.nucleus.vulkan.Vulkan10.Extensions;
99
import com.nucleus.vulkan.Vulkan10.Format;
10+
import com.nucleus.vulkan.Vulkan10.PipelineCreateFlagBits;
1011
import com.nucleus.vulkan.Vulkan10.PresentModeKHR;
12+
import com.nucleus.vulkan.Vulkan10.ShaderStageFlagBits;
1113
import com.nucleus.vulkan.Vulkan10.SurfaceFormat;
1214
import com.nucleus.vulkan.VulkanWrapper.VulkanDeviceSelector;
1315
import com.nucleus.vulkan.shader.VulkanShaderBinary;
1416
import com.nucleus.vulkan.structs.Extent2D;
17+
import com.nucleus.vulkan.structs.GraphicsPipelineCreateInfo;
18+
import com.nucleus.vulkan.structs.GraphicsPipelines;
1519
import com.nucleus.vulkan.structs.ImageView;
1620
import com.nucleus.vulkan.structs.ImageViewCreateInfo;
1721
import com.nucleus.vulkan.structs.PhysicalDeviceMemoryProperties;
1822
import com.nucleus.vulkan.structs.PhysicalDeviceProperties.PhysicalDeviceType;
23+
import com.nucleus.vulkan.structs.PipelineShaderStageCreateInfo;
24+
import com.nucleus.vulkan.structs.PipelineShaderStageCreateInfo.SpecializationInfo;
1925
import com.nucleus.vulkan.structs.QueueFamilyProperties;
2026
import com.nucleus.vulkan.structs.QueueFamilyProperties.QueueFlagBits;
2127
import com.nucleus.vulkan.structs.ShaderModule;
@@ -178,6 +184,11 @@ protected abstract SwapChain createSwapChain(PhysicalDevice device, SurfaceForma
178184
*/
179185
protected abstract ShaderModule createShaderModule(VulkanShaderBinary binary);
180186

187+
protected abstract PipelineShaderStageCreateInfo createShaderStageInfo(PipelineCreateFlagBits[] flags,
188+
ShaderStageFlagBits stage, ShaderModule module, String name, SpecializationInfo specializationInfo);
189+
190+
protected abstract GraphicsPipelines createGraphicsPipelines(GraphicsPipelineCreateInfo info);
191+
181192
@Override
182193
public PhysicalDevice selectDevice(PhysicalDevice[] devices) {
183194
ArrayList<PhysicalDevice> validDevices = new ArrayList<>();

0 commit comments

Comments
 (0)