mirror of https://github.com/bjornbytes/lovr.git
Rework device info;
This commit is contained in:
parent
be1cedc922
commit
3ae0ff568f
|
@ -26,13 +26,12 @@ static int l_lovrGraphicsGetDevice(lua_State* L) {
|
||||||
GraphicsDevice device;
|
GraphicsDevice device;
|
||||||
lovrGraphicsGetDevice(&device);
|
lovrGraphicsGetDevice(&device);
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushboolean(L, device.discrete), lua_setfield(L, -2, "discrete");
|
lua_pushinteger(L, device.deviceId), lua_setfield(L, -2, "id");
|
||||||
lua_pushinteger(L, device.serial), lua_setfield(L, -2, "id");
|
lua_pushinteger(L, device.vendorId), lua_setfield(L, -2, "vendor");
|
||||||
lua_pushinteger(L, device.vendor), lua_setfield(L, -2, "vendor");
|
|
||||||
lua_pushinteger(L, device.version), lua_setfield(L, -2, "driver");
|
|
||||||
lua_pushstring(L, device.name), lua_setfield(L, -2, "name");
|
lua_pushstring(L, device.name), lua_setfield(L, -2, "name");
|
||||||
lua_pushstring(L, device.renderer), lua_setfield(L, -2, "renderer");
|
lua_pushstring(L, device.renderer), lua_setfield(L, -2, "renderer");
|
||||||
lua_pushinteger(L, device.subgroupSize), lua_setfield(L, -2, "subgroupSize");
|
lua_pushinteger(L, device.subgroupSize), lua_setfield(L, -2, "subgroupSize");
|
||||||
|
lua_pushboolean(L, device.discrete), lua_setfield(L, -2, "discrete");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool discrete;
|
uint32_t deviceId;
|
||||||
uint32_t serial;
|
uint32_t vendorId;
|
||||||
uint32_t vendor;
|
char deviceName[256];
|
||||||
uint32_t version;
|
|
||||||
char name[256];
|
|
||||||
const char* renderer;
|
const char* renderer;
|
||||||
uint32_t subgroupSize;
|
uint32_t subgroupSize;
|
||||||
} gpu_device;
|
bool discrete;
|
||||||
|
} gpu_device_info;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool bptc;
|
bool bptc;
|
||||||
|
@ -54,7 +53,7 @@ typedef struct {
|
||||||
bool debug;
|
bool debug;
|
||||||
void* userdata;
|
void* userdata;
|
||||||
void (*callback)(void* userdata, const char* message, bool error);
|
void (*callback)(void* userdata, const char* message, bool error);
|
||||||
gpu_device* device;
|
gpu_device_info* device;
|
||||||
gpu_features* features;
|
gpu_features* features;
|
||||||
gpu_limits* limits;
|
gpu_limits* limits;
|
||||||
} gpu_config;
|
} gpu_config;
|
||||||
|
|
|
@ -230,13 +230,12 @@ bool gpu_init(gpu_config* config) {
|
||||||
|
|
||||||
if (config->device) {
|
if (config->device) {
|
||||||
VkPhysicalDeviceProperties* properties = &properties2.properties;
|
VkPhysicalDeviceProperties* properties = &properties2.properties;
|
||||||
config->device->discrete = properties->deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
|
config->device->deviceId = properties->deviceID;
|
||||||
config->device->serial = properties->deviceID;
|
config->device->vendorId = properties->vendorID;
|
||||||
config->device->vendor = properties->vendorID;
|
memcpy(config->device->deviceName, properties->deviceName, MIN(sizeof(config->device->deviceName), sizeof(properties->deviceName)));
|
||||||
config->device->version = properties->driverVersion;
|
|
||||||
memcpy(config->device->name, properties->deviceName, MIN(sizeof(config->device->name), sizeof(properties->deviceName)));
|
|
||||||
config->device->renderer = "Vulkan";
|
config->device->renderer = "Vulkan";
|
||||||
config->device->subgroupSize = subgroupProperties.subgroupSize;
|
config->device->subgroupSize = subgroupProperties.subgroupSize;
|
||||||
|
config->device->discrete = properties->deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->limits) {
|
if (config->limits) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
bool initialized;
|
bool initialized;
|
||||||
gpu_device device;
|
gpu_device_info device;
|
||||||
gpu_features features;
|
gpu_features features;
|
||||||
gpu_limits limits;
|
gpu_limits limits;
|
||||||
} state;
|
} state;
|
||||||
|
@ -42,13 +42,12 @@ void lovrGraphicsDestroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGraphicsGetDevice(GraphicsDevice* device) {
|
void lovrGraphicsGetDevice(GraphicsDevice* device) {
|
||||||
device->discrete = state.device.discrete;
|
device->deviceId = state.device.deviceId;
|
||||||
device->serial = state.device.serial;
|
device->vendorId = state.device.vendorId;
|
||||||
device->vendor = state.device.vendor;
|
device->name = state.device.deviceName;
|
||||||
device->version = state.device.version;
|
|
||||||
device->name = state.device.name;
|
|
||||||
device->renderer = state.device.renderer;
|
device->renderer = state.device.renderer;
|
||||||
device->subgroupSize = state.device.subgroupSize;
|
device->subgroupSize = state.device.subgroupSize;
|
||||||
|
device->discrete = state.device.discrete;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGraphicsGetFeatures(GraphicsFeatures* features) {
|
void lovrGraphicsGetFeatures(GraphicsFeatures* features) {
|
||||||
|
|
|
@ -4,13 +4,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool discrete;
|
uint32_t deviceId;
|
||||||
uint32_t serial;
|
uint32_t vendorId;
|
||||||
uint32_t vendor;
|
|
||||||
uint32_t version;
|
|
||||||
const char* name;
|
const char* name;
|
||||||
const char* renderer;
|
const char* renderer;
|
||||||
uint32_t subgroupSize;
|
uint32_t subgroupSize;
|
||||||
|
bool discrete;
|
||||||
} GraphicsDevice;
|
} GraphicsDevice;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue