Rework device info;

This commit is contained in:
bjorn 2022-04-22 13:28:59 -07:00
parent be1cedc922
commit 3ae0ff568f
5 changed files with 21 additions and 26 deletions

View File

@ -26,13 +26,12 @@ static int l_lovrGraphicsGetDevice(lua_State* L) {
GraphicsDevice device;
lovrGraphicsGetDevice(&device);
lua_newtable(L);
lua_pushboolean(L, device.discrete), lua_setfield(L, -2, "discrete");
lua_pushinteger(L, device.serial), lua_setfield(L, -2, "id");
lua_pushinteger(L, device.vendor), lua_setfield(L, -2, "vendor");
lua_pushinteger(L, device.version), lua_setfield(L, -2, "driver");
lua_pushinteger(L, device.deviceId), lua_setfield(L, -2, "id");
lua_pushinteger(L, device.vendorId), lua_setfield(L, -2, "vendor");
lua_pushstring(L, device.name), lua_setfield(L, -2, "name");
lua_pushstring(L, device.renderer), lua_setfield(L, -2, "renderer");
lua_pushinteger(L, device.subgroupSize), lua_setfield(L, -2, "subgroupSize");
lua_pushboolean(L, device.discrete), lua_setfield(L, -2, "discrete");
return 1;
}

View File

@ -2,14 +2,13 @@
#include <stdint.h>
typedef struct {
bool discrete;
uint32_t serial;
uint32_t vendor;
uint32_t version;
char name[256];
uint32_t deviceId;
uint32_t vendorId;
char deviceName[256];
const char* renderer;
uint32_t subgroupSize;
} gpu_device;
bool discrete;
} gpu_device_info;
typedef struct {
bool bptc;
@ -54,7 +53,7 @@ typedef struct {
bool debug;
void* userdata;
void (*callback)(void* userdata, const char* message, bool error);
gpu_device* device;
gpu_device_info* device;
gpu_features* features;
gpu_limits* limits;
} gpu_config;

View File

@ -230,13 +230,12 @@ bool gpu_init(gpu_config* config) {
if (config->device) {
VkPhysicalDeviceProperties* properties = &properties2.properties;
config->device->discrete = properties->deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
config->device->serial = properties->deviceID;
config->device->vendor = properties->vendorID;
config->device->version = properties->driverVersion;
memcpy(config->device->name, properties->deviceName, MIN(sizeof(config->device->name), sizeof(properties->deviceName)));
config->device->deviceId = properties->deviceID;
config->device->vendorId = properties->vendorID;
memcpy(config->device->deviceName, properties->deviceName, MIN(sizeof(config->device->deviceName), sizeof(properties->deviceName)));
config->device->renderer = "Vulkan";
config->device->subgroupSize = subgroupProperties.subgroupSize;
config->device->discrete = properties->deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
}
if (config->limits) {

View File

@ -5,7 +5,7 @@
static struct {
bool initialized;
gpu_device device;
gpu_device_info device;
gpu_features features;
gpu_limits limits;
} state;
@ -42,13 +42,12 @@ void lovrGraphicsDestroy() {
}
void lovrGraphicsGetDevice(GraphicsDevice* device) {
device->discrete = state.device.discrete;
device->serial = state.device.serial;
device->vendor = state.device.vendor;
device->version = state.device.version;
device->name = state.device.name;
device->deviceId = state.device.deviceId;
device->vendorId = state.device.vendorId;
device->name = state.device.deviceName;
device->renderer = state.device.renderer;
device->subgroupSize = state.device.subgroupSize;
device->discrete = state.device.discrete;
}
void lovrGraphicsGetFeatures(GraphicsFeatures* features) {

View File

@ -4,13 +4,12 @@
#pragma once
typedef struct {
bool discrete;
uint32_t serial;
uint32_t vendor;
uint32_t version;
uint32_t deviceId;
uint32_t vendorId;
const char* name;
const char* renderer;
uint32_t subgroupSize;
bool discrete;
} GraphicsDevice;
typedef struct {