Merge commit '3a7f96fd99528968c39b5be81db067ca018d432b' into dev
This commit is contained in:
251
external/SDL/test/testgpu_spinning_cube.c
vendored
251
external/SDL/test/testgpu_spinning_cube.c
vendored
@@ -42,7 +42,7 @@ typedef struct RenderState
|
||||
typedef struct WindowState
|
||||
{
|
||||
int angle_x, angle_y, angle_z;
|
||||
SDL_GPUTexture *tex_depth, *tex_msaa;
|
||||
SDL_GPUTexture *tex_depth, *tex_msaa, *tex_resolve;
|
||||
Uint32 prev_drawablew, prev_drawableh;
|
||||
} WindowState;
|
||||
|
||||
@@ -59,6 +59,7 @@ static void shutdownGPU(void)
|
||||
WindowState *winstate = &window_states[i];
|
||||
SDL_ReleaseGPUTexture(gpu_device, winstate->tex_depth);
|
||||
SDL_ReleaseGPUTexture(gpu_device, winstate->tex_msaa);
|
||||
SDL_ReleaseGPUTexture(gpu_device, winstate->tex_resolve);
|
||||
SDL_ReleaseWindowFromGPUDevice(gpu_device, state->windows[i]);
|
||||
}
|
||||
SDL_free(window_states);
|
||||
@@ -249,20 +250,20 @@ static const VertexData vertex_data[] = {
|
||||
static SDL_GPUTexture*
|
||||
CreateDepthTexture(Uint32 drawablew, Uint32 drawableh)
|
||||
{
|
||||
SDL_GPUTextureCreateInfo depthtex_createinfo;
|
||||
SDL_GPUTextureCreateInfo createinfo;
|
||||
SDL_GPUTexture *result;
|
||||
|
||||
depthtex_createinfo.type = SDL_GPU_TEXTURETYPE_2D;
|
||||
depthtex_createinfo.format = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
|
||||
depthtex_createinfo.width = drawablew;
|
||||
depthtex_createinfo.height = drawableh;
|
||||
depthtex_createinfo.layerCountOrDepth = 1;
|
||||
depthtex_createinfo.levelCount = 1;
|
||||
depthtex_createinfo.sampleCount = render_state.sample_count;
|
||||
depthtex_createinfo.usageFlags = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET;
|
||||
depthtex_createinfo.props = 0;
|
||||
createinfo.type = SDL_GPU_TEXTURETYPE_2D;
|
||||
createinfo.format = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
|
||||
createinfo.width = drawablew;
|
||||
createinfo.height = drawableh;
|
||||
createinfo.layer_count_or_depth = 1;
|
||||
createinfo.num_levels = 1;
|
||||
createinfo.sample_count = render_state.sample_count;
|
||||
createinfo.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET;
|
||||
createinfo.props = 0;
|
||||
|
||||
result = SDL_CreateGPUTexture(gpu_device, &depthtex_createinfo);
|
||||
result = SDL_CreateGPUTexture(gpu_device, &createinfo);
|
||||
CHECK_CREATE(result, "Depth Texture")
|
||||
|
||||
return result;
|
||||
@@ -271,43 +272,68 @@ CreateDepthTexture(Uint32 drawablew, Uint32 drawableh)
|
||||
static SDL_GPUTexture*
|
||||
CreateMSAATexture(Uint32 drawablew, Uint32 drawableh)
|
||||
{
|
||||
SDL_GPUTextureCreateInfo msaatex_createinfo;
|
||||
SDL_GPUTextureCreateInfo createinfo;
|
||||
SDL_GPUTexture *result;
|
||||
|
||||
if (render_state.sample_count == SDL_GPU_SAMPLECOUNT_1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msaatex_createinfo.type = SDL_GPU_TEXTURETYPE_2D;
|
||||
msaatex_createinfo.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
msaatex_createinfo.width = drawablew;
|
||||
msaatex_createinfo.height = drawableh;
|
||||
msaatex_createinfo.layerCountOrDepth = 1;
|
||||
msaatex_createinfo.levelCount = 1;
|
||||
msaatex_createinfo.sampleCount = render_state.sample_count;
|
||||
msaatex_createinfo.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;
|
||||
msaatex_createinfo.props = 0;
|
||||
createinfo.type = SDL_GPU_TEXTURETYPE_2D;
|
||||
createinfo.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
createinfo.width = drawablew;
|
||||
createinfo.height = drawableh;
|
||||
createinfo.layer_count_or_depth = 1;
|
||||
createinfo.num_levels = 1;
|
||||
createinfo.sample_count = render_state.sample_count;
|
||||
createinfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET;
|
||||
createinfo.props = 0;
|
||||
|
||||
result = SDL_CreateGPUTexture(gpu_device, &msaatex_createinfo);
|
||||
result = SDL_CreateGPUTexture(gpu_device, &createinfo);
|
||||
CHECK_CREATE(result, "MSAA Texture")
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_GPUTexture *
|
||||
CreateResolveTexture(Uint32 drawablew, Uint32 drawableh)
|
||||
{
|
||||
SDL_GPUTextureCreateInfo createinfo;
|
||||
SDL_GPUTexture *result;
|
||||
|
||||
if (render_state.sample_count == SDL_GPU_SAMPLECOUNT_1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
createinfo.type = SDL_GPU_TEXTURETYPE_2D;
|
||||
createinfo.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
createinfo.width = drawablew;
|
||||
createinfo.height = drawableh;
|
||||
createinfo.layer_count_or_depth = 1;
|
||||
createinfo.num_levels = 1;
|
||||
createinfo.sample_count = SDL_GPU_SAMPLECOUNT_1;
|
||||
createinfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;
|
||||
createinfo.props = 0;
|
||||
|
||||
result = SDL_CreateGPUTexture(gpu_device, &createinfo);
|
||||
CHECK_CREATE(result, "Resolve Texture")
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
Render(SDL_Window *window, const int windownum)
|
||||
{
|
||||
WindowState *winstate = &window_states[windownum];
|
||||
SDL_GPUTexture *swapchain;
|
||||
SDL_GPUColorAttachmentInfo color_attachment;
|
||||
SDL_GPUDepthStencilAttachmentInfo depth_attachment;
|
||||
SDL_GPUColorTargetInfo color_target;
|
||||
SDL_GPUDepthStencilTargetInfo depth_target;
|
||||
float matrix_rotate[16], matrix_modelview[16], matrix_perspective[16], matrix_final[16];
|
||||
Uint32 drawablew, drawableh;
|
||||
SDL_GPUCommandBuffer *cmd;
|
||||
SDL_GPURenderPass *pass;
|
||||
SDL_GPUBufferBinding vertex_binding;
|
||||
SDL_GPUBlitRegion src_region;
|
||||
SDL_GPUBlitRegion dst_region;
|
||||
SDL_GPUBlitInfo blit_info;
|
||||
|
||||
/* Acquire the swapchain texture */
|
||||
|
||||
@@ -355,26 +381,39 @@ Render(SDL_Window *window, const int windownum)
|
||||
if (winstate->prev_drawablew != drawablew || winstate->prev_drawableh != drawableh) {
|
||||
SDL_ReleaseGPUTexture(gpu_device, winstate->tex_depth);
|
||||
SDL_ReleaseGPUTexture(gpu_device, winstate->tex_msaa);
|
||||
SDL_ReleaseGPUTexture(gpu_device, winstate->tex_resolve);
|
||||
winstate->tex_depth = CreateDepthTexture(drawablew, drawableh);
|
||||
winstate->tex_msaa = CreateMSAATexture(drawablew, drawableh);
|
||||
winstate->tex_resolve = CreateResolveTexture(drawablew, drawableh);
|
||||
}
|
||||
winstate->prev_drawablew = drawablew;
|
||||
winstate->prev_drawableh = drawableh;
|
||||
|
||||
/* Set up the pass */
|
||||
|
||||
SDL_zero(color_attachment);
|
||||
color_attachment.clearColor.a = 1.0f;
|
||||
color_attachment.loadOp = SDL_GPU_LOADOP_CLEAR;
|
||||
color_attachment.storeOp = SDL_GPU_STOREOP_STORE;
|
||||
color_attachment.texture = winstate->tex_msaa ? winstate->tex_msaa : swapchain;
|
||||
SDL_zero(color_target);
|
||||
color_target.clear_color.a = 1.0f;
|
||||
if (winstate->tex_msaa) {
|
||||
color_target.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
color_target.store_op = SDL_GPU_STOREOP_RESOLVE;
|
||||
color_target.texture = winstate->tex_msaa;
|
||||
color_target.resolve_texture = winstate->tex_resolve;
|
||||
color_target.cycle = true;
|
||||
color_target.cycle_resolve_texture = true;
|
||||
} else {
|
||||
color_target.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
color_target.store_op = SDL_GPU_STOREOP_STORE;
|
||||
color_target.texture = swapchain;
|
||||
}
|
||||
|
||||
SDL_zero(depth_attachment);
|
||||
depth_attachment.depthStencilClearValue.depth = 1.0f;
|
||||
depth_attachment.loadOp = SDL_GPU_LOADOP_CLEAR;
|
||||
depth_attachment.storeOp = SDL_GPU_STOREOP_DONT_CARE;
|
||||
depth_attachment.texture = winstate->tex_depth;
|
||||
depth_attachment.cycle = SDL_TRUE;
|
||||
SDL_zero(depth_target);
|
||||
depth_target.clear_depth = 1.0f;
|
||||
depth_target.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
depth_target.store_op = SDL_GPU_STOREOP_DONT_CARE;
|
||||
depth_target.stencil_load_op = SDL_GPU_LOADOP_DONT_CARE;
|
||||
depth_target.stencil_store_op = SDL_GPU_STOREOP_DONT_CARE;
|
||||
depth_target.texture = winstate->tex_depth;
|
||||
depth_target.cycle = true;
|
||||
|
||||
/* Set up the bindings */
|
||||
|
||||
@@ -385,23 +424,27 @@ Render(SDL_Window *window, const int windownum)
|
||||
|
||||
SDL_PushGPUVertexUniformData(cmd, 0, matrix_final, sizeof(matrix_final));
|
||||
|
||||
pass = SDL_BeginGPURenderPass(cmd, &color_attachment, 1, &depth_attachment);
|
||||
pass = SDL_BeginGPURenderPass(cmd, &color_target, 1, &depth_target);
|
||||
SDL_BindGPUGraphicsPipeline(pass, render_state.pipeline);
|
||||
SDL_BindGPUVertexBuffers(pass, 0, &vertex_binding, 1);
|
||||
SDL_DrawGPUPrimitives(pass, 36, 1, 0, 0);
|
||||
SDL_EndGPURenderPass(pass);
|
||||
|
||||
/* Blit MSAA to swapchain, if needed */
|
||||
/* Blit MSAA resolve target to swapchain, if needed */
|
||||
if (render_state.sample_count > SDL_GPU_SAMPLECOUNT_1) {
|
||||
SDL_zero(src_region);
|
||||
src_region.texture = winstate->tex_msaa;
|
||||
src_region.w = drawablew;
|
||||
src_region.h = drawableh;
|
||||
SDL_zero(blit_info);
|
||||
blit_info.source.texture = winstate->tex_resolve;
|
||||
blit_info.source.w = drawablew;
|
||||
blit_info.source.h = drawableh;
|
||||
|
||||
dst_region = src_region;
|
||||
dst_region.texture = swapchain;
|
||||
blit_info.destination.texture = swapchain;
|
||||
blit_info.destination.w = drawablew;
|
||||
blit_info.destination.h = drawableh;
|
||||
|
||||
SDL_BlitGPUTexture(cmd, &src_region, &dst_region, SDL_FLIP_NONE, SDL_GPU_FILTER_LINEAR, SDL_FALSE);
|
||||
blit_info.load_op = SDL_GPU_LOADOP_DONT_CARE;
|
||||
blit_info.filter = SDL_GPU_FILTER_LINEAR;
|
||||
|
||||
SDL_BlitGPUTexture(cmd, &blit_info);
|
||||
}
|
||||
|
||||
/* Submit the command buffer! */
|
||||
@@ -411,36 +454,36 @@ Render(SDL_Window *window, const int windownum)
|
||||
}
|
||||
|
||||
static SDL_GPUShader*
|
||||
load_shader(SDL_bool is_vertex)
|
||||
load_shader(bool is_vertex)
|
||||
{
|
||||
SDL_GPUShaderCreateInfo createinfo;
|
||||
createinfo.samplerCount = 0;
|
||||
createinfo.storageBufferCount = 0;
|
||||
createinfo.storageTextureCount = 0;
|
||||
createinfo.uniformBufferCount = is_vertex ? 1 : 0;
|
||||
createinfo.num_samplers = 0;
|
||||
createinfo.num_storage_buffers = 0;
|
||||
createinfo.num_storage_textures = 0;
|
||||
createinfo.num_uniform_buffers = is_vertex ? 1 : 0;
|
||||
createinfo.props = 0;
|
||||
|
||||
SDL_GPUDriver backend = SDL_GetGPUDriver(gpu_device);
|
||||
if (backend == SDL_GPU_DRIVER_D3D11) {
|
||||
SDL_GPUShaderFormat format = SDL_GetGPUShaderFormats(gpu_device);
|
||||
if (format & SDL_GPU_SHADERFORMAT_DXBC) {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_DXBC;
|
||||
createinfo.code = is_vertex ? D3D11_CubeVert : D3D11_CubeFrag;
|
||||
createinfo.codeSize = is_vertex ? SDL_arraysize(D3D11_CubeVert) : SDL_arraysize(D3D11_CubeFrag);
|
||||
createinfo.entryPointName = is_vertex ? "VSMain" : "PSMain";
|
||||
} else if (backend == SDL_GPU_DRIVER_D3D12) {
|
||||
createinfo.code_size = is_vertex ? SDL_arraysize(D3D11_CubeVert) : SDL_arraysize(D3D11_CubeFrag);
|
||||
createinfo.entrypoint = is_vertex ? "VSMain" : "PSMain";
|
||||
} else if (format & SDL_GPU_SHADERFORMAT_DXIL) {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_DXIL;
|
||||
createinfo.code = is_vertex ? D3D12_CubeVert : D3D12_CubeFrag;
|
||||
createinfo.codeSize = is_vertex ? SDL_arraysize(D3D12_CubeVert) : SDL_arraysize(D3D12_CubeFrag);
|
||||
createinfo.entryPointName = is_vertex ? "VSMain" : "PSMain";
|
||||
} else if (backend == SDL_GPU_DRIVER_METAL) {
|
||||
createinfo.code_size = is_vertex ? SDL_arraysize(D3D12_CubeVert) : SDL_arraysize(D3D12_CubeFrag);
|
||||
createinfo.entrypoint = is_vertex ? "VSMain" : "PSMain";
|
||||
} else if (format & SDL_GPU_SHADERFORMAT_METALLIB) {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_METALLIB;
|
||||
createinfo.code = is_vertex ? cube_vert_metallib : cube_frag_metallib;
|
||||
createinfo.codeSize = is_vertex ? cube_vert_metallib_len : cube_frag_metallib_len;
|
||||
createinfo.entryPointName = is_vertex ? "vs_main" : "fs_main";
|
||||
createinfo.code_size = is_vertex ? cube_vert_metallib_len : cube_frag_metallib_len;
|
||||
createinfo.entrypoint = is_vertex ? "vs_main" : "fs_main";
|
||||
} else {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_SPIRV;
|
||||
createinfo.code = is_vertex ? cube_vert_spv : cube_frag_spv;
|
||||
createinfo.codeSize = is_vertex ? cube_vert_spv_len : cube_frag_spv_len;
|
||||
createinfo.entryPointName = "main";
|
||||
createinfo.code_size = is_vertex ? cube_vert_spv_len : cube_frag_spv_len;
|
||||
createinfo.entrypoint = "main";
|
||||
}
|
||||
|
||||
createinfo.stage = is_vertex ? SDL_GPU_SHADERSTAGE_VERTEX : SDL_GPU_SHADERSTAGE_FRAGMENT;
|
||||
@@ -459,17 +502,17 @@ init_render_state(int msaa)
|
||||
SDL_GPUBufferCreateInfo buffer_desc;
|
||||
SDL_GPUTransferBufferCreateInfo transfer_buffer_desc;
|
||||
SDL_GPUGraphicsPipelineCreateInfo pipelinedesc;
|
||||
SDL_GPUColorAttachmentDescription color_attachment_desc;
|
||||
SDL_GPUColorTargetDescription color_target_desc;
|
||||
Uint32 drawablew, drawableh;
|
||||
SDL_GPUVertexAttribute vertex_attributes[2];
|
||||
SDL_GPUVertexBinding vertex_binding;
|
||||
SDL_GPUVertexBufferDescription vertex_buffer_desc;
|
||||
SDL_GPUShader *vertex_shader;
|
||||
SDL_GPUShader *fragment_shader;
|
||||
int i;
|
||||
|
||||
gpu_device = SDL_CreateGPUDevice(
|
||||
TESTGPU_SUPPORTED_FORMATS,
|
||||
SDL_TRUE,
|
||||
true,
|
||||
state->gpudriver
|
||||
);
|
||||
CHECK_CREATE(gpu_device, "GPU device");
|
||||
@@ -485,15 +528,15 @@ init_render_state(int msaa)
|
||||
|
||||
/* Create shaders */
|
||||
|
||||
vertex_shader = load_shader(SDL_TRUE);
|
||||
vertex_shader = load_shader(true);
|
||||
CHECK_CREATE(vertex_shader, "Vertex Shader")
|
||||
fragment_shader = load_shader(SDL_FALSE);
|
||||
fragment_shader = load_shader(false);
|
||||
CHECK_CREATE(fragment_shader, "Fragment Shader")
|
||||
|
||||
/* Create buffers */
|
||||
|
||||
buffer_desc.usageFlags = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||
buffer_desc.sizeInBytes = sizeof(vertex_data);
|
||||
buffer_desc.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||
buffer_desc.size = sizeof(vertex_data);
|
||||
buffer_desc.props = 0;
|
||||
render_state.buf_vertex = SDL_CreateGPUBuffer(
|
||||
gpu_device,
|
||||
@@ -504,7 +547,7 @@ init_render_state(int msaa)
|
||||
SDL_SetGPUBufferName(gpu_device, render_state.buf_vertex, "космонавт");
|
||||
|
||||
transfer_buffer_desc.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
|
||||
transfer_buffer_desc.sizeInBytes = sizeof(vertex_data);
|
||||
transfer_buffer_desc.size = sizeof(vertex_data);
|
||||
transfer_buffer_desc.props = 0;
|
||||
buf_transfer = SDL_CreateGPUTransferBuffer(
|
||||
gpu_device,
|
||||
@@ -513,18 +556,18 @@ init_render_state(int msaa)
|
||||
CHECK_CREATE(buf_transfer, "Vertex transfer buffer")
|
||||
|
||||
/* We just need to upload the static data once. */
|
||||
map = SDL_MapGPUTransferBuffer(gpu_device, buf_transfer, SDL_FALSE);
|
||||
map = SDL_MapGPUTransferBuffer(gpu_device, buf_transfer, false);
|
||||
SDL_memcpy(map, vertex_data, sizeof(vertex_data));
|
||||
SDL_UnmapGPUTransferBuffer(gpu_device, buf_transfer);
|
||||
|
||||
cmd = SDL_AcquireGPUCommandBuffer(gpu_device);
|
||||
copy_pass = SDL_BeginGPUCopyPass(cmd);
|
||||
buf_location.transferBuffer = buf_transfer;
|
||||
buf_location.transfer_buffer = buf_transfer;
|
||||
buf_location.offset = 0;
|
||||
dst_region.buffer = render_state.buf_vertex;
|
||||
dst_region.offset = 0;
|
||||
dst_region.size = sizeof(vertex_data);
|
||||
SDL_UploadToGPUBuffer(copy_pass, &buf_location, &dst_region, SDL_FALSE);
|
||||
SDL_UploadToGPUBuffer(copy_pass, &buf_location, &dst_region, false);
|
||||
SDL_EndGPUCopyPass(copy_pass);
|
||||
SDL_SubmitGPUCommandBuffer(cmd);
|
||||
|
||||
@@ -542,54 +585,45 @@ init_render_state(int msaa)
|
||||
/* Set up the graphics pipeline */
|
||||
|
||||
SDL_zero(pipelinedesc);
|
||||
SDL_zero(color_target_desc);
|
||||
|
||||
color_attachment_desc.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
color_target_desc.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
|
||||
color_attachment_desc.blendState.blendEnable = 0;
|
||||
color_attachment_desc.blendState.alphaBlendOp = SDL_GPU_BLENDOP_ADD;
|
||||
color_attachment_desc.blendState.colorBlendOp = SDL_GPU_BLENDOP_ADD;
|
||||
color_attachment_desc.blendState.colorWriteMask = 0xF;
|
||||
color_attachment_desc.blendState.srcAlphaBlendFactor = SDL_GPU_BLENDFACTOR_ONE;
|
||||
color_attachment_desc.blendState.dstAlphaBlendFactor = SDL_GPU_BLENDFACTOR_ZERO;
|
||||
color_attachment_desc.blendState.srcColorBlendFactor = SDL_GPU_BLENDFACTOR_ONE;
|
||||
color_attachment_desc.blendState.dstColorBlendFactor = SDL_GPU_BLENDFACTOR_ZERO;
|
||||
pipelinedesc.target_info.num_color_targets = 1;
|
||||
pipelinedesc.target_info.color_target_descriptions = &color_target_desc;
|
||||
pipelinedesc.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
|
||||
pipelinedesc.target_info.has_depth_stencil_target = true;
|
||||
|
||||
pipelinedesc.attachmentInfo.colorAttachmentCount = 1;
|
||||
pipelinedesc.attachmentInfo.colorAttachmentDescriptions = &color_attachment_desc;
|
||||
pipelinedesc.attachmentInfo.depthStencilFormat = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
|
||||
pipelinedesc.attachmentInfo.hasDepthStencilAttachment = SDL_TRUE;
|
||||
pipelinedesc.depth_stencil_state.enable_depth_test = true;
|
||||
pipelinedesc.depth_stencil_state.enable_depth_write = true;
|
||||
pipelinedesc.depth_stencil_state.compare_op = SDL_GPU_COMPAREOP_LESS_OR_EQUAL;
|
||||
|
||||
pipelinedesc.depthStencilState.depthTestEnable = 1;
|
||||
pipelinedesc.depthStencilState.depthWriteEnable = 1;
|
||||
pipelinedesc.depthStencilState.compareOp = SDL_GPU_COMPAREOP_LESS_OR_EQUAL;
|
||||
pipelinedesc.multisample_state.sample_count = render_state.sample_count;
|
||||
|
||||
pipelinedesc.multisampleState.sampleCount = render_state.sample_count;
|
||||
pipelinedesc.multisampleState.sampleMask = 0xF;
|
||||
pipelinedesc.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST;
|
||||
|
||||
pipelinedesc.primitiveType = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST;
|
||||
pipelinedesc.vertex_shader = vertex_shader;
|
||||
pipelinedesc.fragment_shader = fragment_shader;
|
||||
|
||||
pipelinedesc.vertexShader = vertex_shader;
|
||||
pipelinedesc.fragmentShader = fragment_shader;
|
||||
vertex_buffer_desc.slot = 0;
|
||||
vertex_buffer_desc.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX;
|
||||
vertex_buffer_desc.instance_step_rate = 0;
|
||||
vertex_buffer_desc.pitch = sizeof(VertexData);
|
||||
|
||||
vertex_binding.binding = 0;
|
||||
vertex_binding.inputRate = SDL_GPU_VERTEXINPUTRATE_VERTEX;
|
||||
vertex_binding.instanceStepRate = 0;
|
||||
vertex_binding.stride = sizeof(VertexData);
|
||||
|
||||
vertex_attributes[0].binding = 0;
|
||||
vertex_attributes[0].buffer_slot = 0;
|
||||
vertex_attributes[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;
|
||||
vertex_attributes[0].location = 0;
|
||||
vertex_attributes[0].offset = 0;
|
||||
|
||||
vertex_attributes[1].binding = 0;
|
||||
vertex_attributes[1].buffer_slot = 0;
|
||||
vertex_attributes[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;
|
||||
vertex_attributes[1].location = 1;
|
||||
vertex_attributes[1].offset = sizeof(float) * 3;
|
||||
|
||||
pipelinedesc.vertexInputState.vertexBindingCount = 1;
|
||||
pipelinedesc.vertexInputState.vertexBindings = &vertex_binding;
|
||||
pipelinedesc.vertexInputState.vertexAttributeCount = 2;
|
||||
pipelinedesc.vertexInputState.vertexAttributes = (SDL_GPUVertexAttribute*) &vertex_attributes;
|
||||
pipelinedesc.vertex_input_state.num_vertex_buffers = 1;
|
||||
pipelinedesc.vertex_input_state.vertex_buffer_descriptions = &vertex_buffer_desc;
|
||||
pipelinedesc.vertex_input_state.num_vertex_attributes = 2;
|
||||
pipelinedesc.vertex_input_state.vertex_attributes = (SDL_GPUVertexAttribute*) &vertex_attributes;
|
||||
|
||||
pipelinedesc.props = 0;
|
||||
|
||||
@@ -615,6 +649,7 @@ init_render_state(int msaa)
|
||||
SDL_GetWindowSizeInPixels(state->windows[i], (int*) &drawablew, (int*) &drawableh);
|
||||
winstate->tex_depth = CreateDepthTexture(drawablew, drawableh);
|
||||
winstate->tex_msaa = CreateMSAATexture(drawablew, drawableh);
|
||||
winstate->tex_resolve = CreateResolveTexture(drawablew, drawableh);
|
||||
|
||||
/* make each window different */
|
||||
winstate->angle_x = (i * 10) % 360;
|
||||
@@ -625,7 +660,7 @@ init_render_state(int msaa)
|
||||
|
||||
static int done = 0;
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
|
||||
Reference in New Issue
Block a user