stuff
This commit is contained in:
parent
ee79b4c195
commit
ef9161fabe
@ -1,7 +1,7 @@
|
|||||||
# linux kernel style formatting
|
# linux kernel style formatting
|
||||||
BasedOnStyle: LLVM
|
BasedOnStyle: LLVM
|
||||||
IndentWidth: 8
|
IndentWidth: 8
|
||||||
UseTab: Always
|
UseTab: AlignWithSpaces
|
||||||
|
|
||||||
BreakBeforeBraces: Linux
|
BreakBeforeBraces: Linux
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
27
test3/README
27
test3/README
@ -1 +1,26 @@
|
|||||||
Trying to implement test2 with just vulkan and in C
|
### Trying to implement test2 with just vulkan and in C
|
||||||
|
|
||||||
|
Just trying to get large matrix multiplication going in C since C++ really fucks with
|
||||||
|
my grey matter
|
||||||
|
|
||||||
|
### Useful links:
|
||||||
|
|
||||||
|
[Vulkan Tutorial](https://vulkan-tutorial.com): A full Vulkan tutorial implemented in C++
|
||||||
|
but it is easy to port to C, the only brain scratcher are lifetimes. Still this is more
|
||||||
|
targeted towards graphics rather than Compute, as such it is not easy to differentiate
|
||||||
|
which parts are needed and which aren't
|
||||||
|
|
||||||
|
[Simple Vulkan Compute Example](https://bakedbits.dev/posts/vulkan-compute-example/):
|
||||||
|
a bit brief, as such easier to skim trough
|
||||||
|
|
||||||
|
[A Simple Vulkan Compute Example](https://www.neilhenning.dev/posts/a-simple-vulkan-compute-example/):
|
||||||
|
This time in C, more complete than the homonymous article and still easy to follow
|
||||||
|
|
||||||
|
[VkGuide](https://vkguide.dev/docs/gpudriven/compute_shaders/): Good resource but not
|
||||||
|
really a tutorial
|
||||||
|
|
||||||
|
[Vulkan Samples](https://github.com/SaschaWillems/Vulkan-Samples): A collection of sample
|
||||||
|
programs, still haven't read trough them but might be good for implementation details
|
||||||
|
|
||||||
|
[VkFFT](https://github.com/DTolm/VkFFT): Fast Fourier Transform on vulkan shader, still
|
||||||
|
haven't looked at it but it might be great to learn more advanced shader techniques
|
||||||
|
35
test3/main.c
35
test3/main.c
@ -6,6 +6,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
// check for half precision floating point support, for x86 this is equivalent to
|
// check for half precision floating point support, for x86 this is equivalent to
|
||||||
// checking for SSE2
|
// checking for SSE2
|
||||||
@ -103,7 +104,8 @@ VkInstance vk_init(void)
|
|||||||
.applicationVersion = VK_MAKE_VERSION(0, 1, 0),
|
.applicationVersion = VK_MAKE_VERSION(0, 1, 0),
|
||||||
.pEngineName = "no engine",
|
.pEngineName = "no engine",
|
||||||
.engineVersion = VK_MAKE_VERSION(0, 0, 0),
|
.engineVersion = VK_MAKE_VERSION(0, 0, 0),
|
||||||
.apiVersion = VK_API_VERSION_1_3,
|
.apiVersion =
|
||||||
|
VK_API_VERSION_1_2, // api version 1.2 is more widely available
|
||||||
};
|
};
|
||||||
|
|
||||||
vk_enumerate_instance_extensions();
|
vk_enumerate_instance_extensions();
|
||||||
@ -153,6 +155,7 @@ void vk_destroy(VkInstance vk_instance)
|
|||||||
|
|
||||||
VkPhysicalDevice vk_physical_device_get(VkInstance vk_instance)
|
VkPhysicalDevice vk_physical_device_get(VkInstance vk_instance)
|
||||||
{
|
{
|
||||||
|
// get the physical devices list
|
||||||
VkPhysicalDevice vk_phydev = VK_NULL_HANDLE;
|
VkPhysicalDevice vk_phydev = VK_NULL_HANDLE;
|
||||||
|
|
||||||
uint32_t vk_phydevs_no = 0;
|
uint32_t vk_phydevs_no = 0;
|
||||||
@ -171,24 +174,38 @@ VkPhysicalDevice vk_physical_device_get(VkInstance vk_instance)
|
|||||||
|
|
||||||
vkEnumeratePhysicalDevices(vk_instance, &vk_phydevs_no, vk_phydevs);
|
vkEnumeratePhysicalDevices(vk_instance, &vk_phydevs_no, vk_phydevs);
|
||||||
|
|
||||||
|
// print out information about each device
|
||||||
printf("Available Physical Devices: \n");
|
printf("Available Physical Devices: \n");
|
||||||
for (uint32_t i = 0; i < vk_phydevs_no; i++) {
|
for (uint32_t i = 0; i < vk_phydevs_no; i++) {
|
||||||
VkPhysicalDevice device = vk_phydevs[i];
|
VkPhysicalDevice dev = vk_phydevs[i];
|
||||||
VkPhysicalDeviceProperties device_properties;
|
VkPhysicalDeviceProperties dev_properties;
|
||||||
VkPhysicalDeviceFeatures device_features;
|
VkPhysicalDeviceFeatures dev_features;
|
||||||
|
VkPhysicalDeviceMemoryProperties dev_memory;
|
||||||
|
|
||||||
vkGetPhysicalDeviceProperties(device, &device_properties);
|
vkGetPhysicalDeviceProperties(dev, &dev_properties);
|
||||||
vkGetPhysicalDeviceFeatures(device, &device_features);
|
vkGetPhysicalDeviceFeatures(dev, &dev_features);
|
||||||
|
vkGetPhysicalDeviceMemoryProperties(dev, &dev_memory);
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
"\tDevice %d: %s, Discrete: %s\n",
|
"\tDevice %d: %s, Discrete: %s\n",
|
||||||
i,
|
i,
|
||||||
device_properties.deviceName,
|
dev_properties.deviceName,
|
||||||
device_properties.deviceType ==
|
dev_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
|
||||||
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
|
|
||||||
? "true"
|
? "true"
|
||||||
: "false"
|
: "false"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (unsigned x = 0; x < dev_memory.memoryHeapCount; x++) {
|
||||||
|
uint64_t mem_size = dev_memory.memoryHeaps[x].size;
|
||||||
|
uint32_t mem_flags = dev_memory.memoryHeaps[x].flags;
|
||||||
|
char mem_local = mem_flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
|
||||||
|
printf(
|
||||||
|
"\t\tHeap %.2d: local: %d, size: %.3f MiB\n",
|
||||||
|
x,
|
||||||
|
mem_local,
|
||||||
|
(float)mem_size / (1024.0 * 1024.0)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: find the most suitable physical device, but for now every vulkan
|
// TODO: find the most suitable physical device, but for now every vulkan
|
||||||
|
Loading…
Reference in New Issue
Block a user