stuff
This commit is contained in:
parent
ee79b4c195
commit
ef9161fabe
@ -1,7 +1,7 @@
|
||||
# linux kernel style formatting
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 8
|
||||
UseTab: Always
|
||||
UseTab: AlignWithSpaces
|
||||
|
||||
BreakBeforeBraces: Linux
|
||||
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 <vulkan/vulkan.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
// check for half precision floating point support, for x86 this is equivalent to
|
||||
// checking for SSE2
|
||||
@ -103,7 +104,8 @@ VkInstance vk_init(void)
|
||||
.applicationVersion = VK_MAKE_VERSION(0, 1, 0),
|
||||
.pEngineName = "no engine",
|
||||
.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();
|
||||
@ -153,6 +155,7 @@ void vk_destroy(VkInstance vk_instance)
|
||||
|
||||
VkPhysicalDevice vk_physical_device_get(VkInstance vk_instance)
|
||||
{
|
||||
// get the physical devices list
|
||||
VkPhysicalDevice vk_phydev = VK_NULL_HANDLE;
|
||||
|
||||
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);
|
||||
|
||||
// print out information about each device
|
||||
printf("Available Physical Devices: \n");
|
||||
for (uint32_t i = 0; i < vk_phydevs_no; i++) {
|
||||
VkPhysicalDevice device = vk_phydevs[i];
|
||||
VkPhysicalDeviceProperties device_properties;
|
||||
VkPhysicalDeviceFeatures device_features;
|
||||
VkPhysicalDevice dev = vk_phydevs[i];
|
||||
VkPhysicalDeviceProperties dev_properties;
|
||||
VkPhysicalDeviceFeatures dev_features;
|
||||
VkPhysicalDeviceMemoryProperties dev_memory;
|
||||
|
||||
vkGetPhysicalDeviceProperties(device, &device_properties);
|
||||
vkGetPhysicalDeviceFeatures(device, &device_features);
|
||||
vkGetPhysicalDeviceProperties(dev, &dev_properties);
|
||||
vkGetPhysicalDeviceFeatures(dev, &dev_features);
|
||||
vkGetPhysicalDeviceMemoryProperties(dev, &dev_memory);
|
||||
|
||||
printf(
|
||||
"\tDevice %d: %s, Discrete: %s\n",
|
||||
i,
|
||||
device_properties.deviceName,
|
||||
device_properties.deviceType ==
|
||||
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
|
||||
dev_properties.deviceName,
|
||||
dev_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
|
||||
? "true"
|
||||
: "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
|
||||
|
Loading…
Reference in New Issue
Block a user