mirror of https://github.com/bjornbytes/lovr.git
Adjust;
This commit is contained in:
parent
0104fe1910
commit
8431fc72ba
|
@ -262,11 +262,15 @@ bool lovrGraphicsInit(bool debug, bool vsync) {
|
||||||
lovrThrow("Failed to initialize GPU");
|
lovrThrow("Failed to initialize GPU");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary frame memory uses a large 1GB virtual memory allocation, committing pages as needed
|
||||||
|
state.allocator.length = 1 << 14;
|
||||||
|
state.allocator.memory = os_vm_init(MAX_FRAME_MEMORY);
|
||||||
|
os_vm_commit(state.allocator.memory, state.allocator.length);
|
||||||
|
|
||||||
map_init(&state.pipelineLookup, 64);
|
map_init(&state.pipelineLookup, 64);
|
||||||
arr_init(&state.pipelines, realloc);
|
arr_init(&state.pipelines, realloc);
|
||||||
arr_init(&state.layouts, realloc);
|
arr_init(&state.layouts, realloc);
|
||||||
|
|
||||||
// Layout for builtin bindings
|
|
||||||
gpu_slot builtins[] = {
|
gpu_slot builtins[] = {
|
||||||
{ 0, GPU_SLOT_UNIFORM_BUFFER, GPU_STAGE_ALL }, // Cameras
|
{ 0, GPU_SLOT_UNIFORM_BUFFER, GPU_STAGE_ALL }, // Cameras
|
||||||
{ 1, GPU_SLOT_UNIFORM_BUFFER, GPU_STAGE_ALL }, // Draw data
|
{ 1, GPU_SLOT_UNIFORM_BUFFER, GPU_STAGE_ALL }, // Draw data
|
||||||
|
@ -275,19 +279,13 @@ bool lovrGraphicsInit(bool debug, bool vsync) {
|
||||||
|
|
||||||
state.builtinLayout = getLayout(builtins, COUNTOF(builtins));
|
state.builtinLayout = getLayout(builtins, COUNTOF(builtins));
|
||||||
|
|
||||||
// Temporary frame memory uses a large 1GB virtual memory allocation, committing pages as needed
|
state.defaultBuffer = lovrBufferCreate(&(BufferInfo) {
|
||||||
state.allocator.length = 1 << 14;
|
|
||||||
state.allocator.memory = os_vm_init(MAX_FRAME_MEMORY);
|
|
||||||
os_vm_commit(state.allocator.memory, state.allocator.length);
|
|
||||||
|
|
||||||
// Default resources
|
|
||||||
BufferInfo defaultBufferInfo = {
|
|
||||||
.length = 4096,
|
.length = 4096,
|
||||||
.stride = 1,
|
.stride = 1,
|
||||||
.label = "Default Buffer"
|
.label = "Default Buffer"
|
||||||
};
|
}, NULL);
|
||||||
|
|
||||||
TextureInfo defaultTextureInfo = {
|
state.defaultTexture = lovrTextureCreate(&(TextureInfo) {
|
||||||
.type = TEXTURE_2D,
|
.type = TEXTURE_2D,
|
||||||
.usage = TEXTURE_SAMPLE | TEXTURE_TRANSFER,
|
.usage = TEXTURE_SAMPLE | TEXTURE_TRANSFER,
|
||||||
.format = FORMAT_RGBA8,
|
.format = FORMAT_RGBA8,
|
||||||
|
@ -298,32 +296,18 @@ bool lovrGraphicsInit(bool debug, bool vsync) {
|
||||||
.samples = 1,
|
.samples = 1,
|
||||||
.srgb = true,
|
.srgb = true,
|
||||||
.label = "Default Texture"
|
.label = "Default Texture"
|
||||||
};
|
});
|
||||||
|
|
||||||
SamplerInfo defaultSamplerInfo = {
|
state.defaultSampler = lovrSamplerCreate(&(SamplerInfo) {
|
||||||
.min = FILTER_LINEAR,
|
.min = FILTER_LINEAR,
|
||||||
.mag = FILTER_LINEAR,
|
.mag = FILTER_LINEAR,
|
||||||
.mip = FILTER_LINEAR,
|
.mip = FILTER_LINEAR,
|
||||||
.wrap = { WRAP_REPEAT, WRAP_REPEAT, WRAP_REPEAT }
|
.wrap = { WRAP_REPEAT, WRAP_REPEAT, WRAP_REPEAT }
|
||||||
};
|
});
|
||||||
|
|
||||||
void* zeros;
|
|
||||||
state.defaultBuffer = lovrBufferCreate(&defaultBufferInfo, &zeros);
|
|
||||||
state.defaultTexture = lovrTextureCreate(&defaultTextureInfo);
|
|
||||||
state.defaultSampler = lovrSamplerCreate(&defaultSamplerInfo);
|
|
||||||
|
|
||||||
gpu_stream* transfers = getTransfers();
|
gpu_stream* transfers = getTransfers();
|
||||||
|
gpu_clear_buffer(transfers, state.defaultBuffer->gpu, 0, 4096);
|
||||||
float white[4] = { 1.f, 1.f, 1.f, 1.f };
|
gpu_clear_texture(transfers, state.defaultTexture->gpu, (float[4]) { 1.f, 1.f, 1.f, 1.f }, 0, ~0u, 0, ~0u);
|
||||||
gpu_clear_texture(transfers, state.defaultTexture->gpu, white, 0, ~0u, 0, ~0u);
|
|
||||||
|
|
||||||
if (!zeros) {
|
|
||||||
gpu_buffer* scratchpad = tempAlloc(gpu_sizeof_buffer());
|
|
||||||
zeros = gpu_map(scratchpad, defaultBufferInfo.length, 4, GPU_MAP_WRITE);
|
|
||||||
gpu_copy_buffers(transfers, scratchpad, state.defaultBuffer->gpu, 0, 0, defaultBufferInfo.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(zeros, 0, defaultBufferInfo.length);
|
|
||||||
|
|
||||||
state.vertexFormats[VERTEX_POINT].gpu = (gpu_vertex_format) {
|
state.vertexFormats[VERTEX_POINT].gpu = (gpu_vertex_format) {
|
||||||
.bufferCount = 2,
|
.bufferCount = 2,
|
||||||
|
|
Loading…
Reference in New Issue