Cleanup
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -58,20 +58,12 @@ static D3D12_BLEND convert_blend_factor(gpu_blending_factor_t factor) {
|
||||
}
|
||||
}
|
||||
|
||||
static D3D12_BLEND_OP convert_blend_operation(gpu_blending_operation_t op) {
|
||||
switch (op) {
|
||||
case GPU_BLENDOP_ADD:
|
||||
return D3D12_BLEND_OP_ADD;
|
||||
}
|
||||
}
|
||||
|
||||
static D3D12_CULL_MODE convert_cull_mode(gpu_cull_mode_t cull_mode) {
|
||||
switch (cull_mode) {
|
||||
case GPU_CULL_MODE_CLOCKWISE:
|
||||
return D3D12_CULL_MODE_FRONT;
|
||||
case GPU_CULL_MODE_COUNTERCLOCKWISE:
|
||||
return D3D12_CULL_MODE_BACK;
|
||||
case GPU_CULL_MODE_NEVER:
|
||||
default:
|
||||
return D3D12_CULL_MODE_NONE;
|
||||
}
|
||||
@@ -782,10 +774,10 @@ void gpu_pipeline_compile(gpu_pipeline_t *pipe) {
|
||||
pipe->alpha_blend_source != GPU_BLEND_ONE || pipe->alpha_blend_destination != GPU_BLEND_ZERO;
|
||||
psoDesc.BlendState.RenderTarget[i].SrcBlend = convert_blend_factor(pipe->blend_source);
|
||||
psoDesc.BlendState.RenderTarget[i].DestBlend = convert_blend_factor(pipe->blend_destination);
|
||||
psoDesc.BlendState.RenderTarget[i].BlendOp = convert_blend_operation(pipe->blend_operation);
|
||||
psoDesc.BlendState.RenderTarget[i].BlendOp = D3D12_BLEND_OP_ADD;
|
||||
psoDesc.BlendState.RenderTarget[i].SrcBlendAlpha = convert_blend_factor(pipe->alpha_blend_source);
|
||||
psoDesc.BlendState.RenderTarget[i].DestBlendAlpha = convert_blend_factor(pipe->alpha_blend_destination);
|
||||
psoDesc.BlendState.RenderTarget[i].BlendOpAlpha = convert_blend_operation(pipe->alpha_blend_operation);
|
||||
psoDesc.BlendState.RenderTarget[i].BlendOpAlpha = D3D12_BLEND_OP_ADD;
|
||||
psoDesc.BlendState.RenderTarget[i].RenderTargetWriteMask =
|
||||
(((pipe->color_write_mask_red[i] ? D3D12_COLOR_WRITE_ENABLE_RED : 0) |
|
||||
(pipe->color_write_mask_green[i] ? D3D12_COLOR_WRITE_ENABLE_GREEN : 0)) |
|
||||
|
||||
@@ -46,13 +46,6 @@ static MTLBlendFactor convert_blending_factor(gpu_blending_factor_t factor) {
|
||||
}
|
||||
}
|
||||
|
||||
static MTLBlendOperation convert_blending_operation(gpu_blending_operation_t op) {
|
||||
switch (op) {
|
||||
case GPU_BLENDOP_ADD:
|
||||
return MTLBlendOperationAdd;
|
||||
}
|
||||
}
|
||||
|
||||
static MTLCompareFunction convert_compare_mode(gpu_compare_mode_t compare) {
|
||||
switch (compare) {
|
||||
case GPU_COMPARE_MODE_ALWAYS:
|
||||
@@ -89,7 +82,6 @@ static MTLPixelFormat convert_texture_format(gpu_texture_format_t format) {
|
||||
return MTLPixelFormatR8Unorm;
|
||||
case GPU_TEXTURE_FORMAT_D32:
|
||||
return MTLPixelFormatDepth32Float;
|
||||
case GPU_TEXTURE_FORMAT_RGBA32:
|
||||
default:
|
||||
return MTLPixelFormatBGRA8Unorm;
|
||||
}
|
||||
@@ -105,8 +97,6 @@ static int format_byte_size(gpu_texture_format_t format) {
|
||||
return 2;
|
||||
case GPU_TEXTURE_FORMAT_R8:
|
||||
return 1;
|
||||
case GPU_TEXTURE_FORMAT_RGBA32:
|
||||
case GPU_TEXTURE_FORMAT_R32:
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
@@ -445,10 +435,10 @@ void gpu_pipeline_compile(gpu_pipeline_t *pipeline) {
|
||||
pipeline->alpha_blend_source != GPU_BLEND_ONE || pipeline->alpha_blend_destination != GPU_BLEND_ZERO;
|
||||
renderPipelineDesc.colorAttachments[i].sourceRGBBlendFactor = convert_blending_factor(pipeline->blend_source);
|
||||
renderPipelineDesc.colorAttachments[i].destinationRGBBlendFactor = convert_blending_factor(pipeline->blend_destination);
|
||||
renderPipelineDesc.colorAttachments[i].rgbBlendOperation = convert_blending_operation(pipeline->blend_operation);
|
||||
renderPipelineDesc.colorAttachments[i].rgbBlendOperation = MTLBlendOperationAdd;
|
||||
renderPipelineDesc.colorAttachments[i].sourceAlphaBlendFactor = convert_blending_factor(pipeline->alpha_blend_source);
|
||||
renderPipelineDesc.colorAttachments[i].destinationAlphaBlendFactor = convert_blending_factor(pipeline->alpha_blend_destination);
|
||||
renderPipelineDesc.colorAttachments[i].alphaBlendOperation = convert_blending_operation(pipeline->alpha_blend_operation);
|
||||
renderPipelineDesc.colorAttachments[i].alphaBlendOperation = MTLBlendOperationAdd;
|
||||
renderPipelineDesc.colorAttachments[i].writeMask =
|
||||
(pipeline->color_write_mask_red[i] ? MTLColorWriteMaskRed : 0) |
|
||||
(pipeline->color_write_mask_green[i] ? MTLColorWriteMaskGreen : 0) |
|
||||
|
||||
@@ -76,9 +76,6 @@ static VkFormat convert_image_format(gpu_texture_format_t format) {
|
||||
return VK_FORMAT_R16_SFLOAT;
|
||||
case GPU_TEXTURE_FORMAT_R32:
|
||||
return VK_FORMAT_R32_SFLOAT;
|
||||
case GPU_TEXTURE_FORMAT_RGBA32:
|
||||
// return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
return VK_FORMAT_B8G8R8A8_UNORM;
|
||||
case GPU_TEXTURE_FORMAT_D32:
|
||||
return VK_FORMAT_D32_SFLOAT;
|
||||
default:
|
||||
@@ -107,7 +104,6 @@ static VkCullModeFlagBits convert_cull_mode(gpu_cull_mode_t cull_mode) {
|
||||
return VK_CULL_MODE_BACK_BIT;
|
||||
case GPU_CULL_MODE_COUNTERCLOCKWISE:
|
||||
return VK_CULL_MODE_FRONT_BIT;
|
||||
case GPU_CULL_MODE_NEVER:
|
||||
default:
|
||||
return VK_CULL_MODE_NONE;
|
||||
}
|
||||
@@ -142,13 +138,6 @@ static VkBlendFactor convert_blend_factor(gpu_blending_factor_t factor) {
|
||||
}
|
||||
}
|
||||
|
||||
static VkBlendOp convert_blend_operation(gpu_blending_operation_t op) {
|
||||
switch (op) {
|
||||
case GPU_BLENDOP_ADD:
|
||||
return VK_BLEND_OP_ADD;
|
||||
}
|
||||
}
|
||||
|
||||
static VkImageLayout convert_texture_state(gpu_texture_state_t state) {
|
||||
switch (state) {
|
||||
case GPU_TEXTURE_STATE_SHADER_RESOURCE:
|
||||
@@ -1549,10 +1538,10 @@ void gpu_pipeline_compile(gpu_pipeline_t *pipeline) {
|
||||
pipeline->alpha_blend_destination != GPU_BLEND_ZERO;
|
||||
att_state[i].srcColorBlendFactor = convert_blend_factor(pipeline->blend_source);
|
||||
att_state[i].dstColorBlendFactor = convert_blend_factor(pipeline->blend_destination);
|
||||
att_state[i].colorBlendOp = convert_blend_operation(pipeline->blend_operation);
|
||||
att_state[i].colorBlendOp = VK_BLEND_OP_ADD;
|
||||
att_state[i].srcAlphaBlendFactor = convert_blend_factor(pipeline->alpha_blend_source);
|
||||
att_state[i].dstAlphaBlendFactor = convert_blend_factor(pipeline->alpha_blend_destination);
|
||||
att_state[i].alphaBlendOp = convert_blend_operation(pipeline->alpha_blend_operation);
|
||||
att_state[i].alphaBlendOp = VK_BLEND_OP_ADD;
|
||||
}
|
||||
cb.attachmentCount = pipeline->color_attachment_count;
|
||||
cb.pAttachments = att_state;
|
||||
|
||||
@@ -232,10 +232,8 @@ void gpu_internal_pipeline_init(gpu_pipeline_t *pipe) {
|
||||
pipe->depth_mode = GPU_COMPARE_MODE_ALWAYS;
|
||||
pipe->blend_source = GPU_BLEND_ONE;
|
||||
pipe->blend_destination = GPU_BLEND_ZERO;
|
||||
pipe->blend_operation = GPU_BLENDOP_ADD;
|
||||
pipe->alpha_blend_source = GPU_BLEND_ONE;
|
||||
pipe->alpha_blend_destination = GPU_BLEND_ZERO;
|
||||
pipe->alpha_blend_operation = GPU_BLENDOP_ADD;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
pipe->color_write_mask_red[i] = true;
|
||||
pipe->color_write_mask_green[i] = true;
|
||||
|
||||
@@ -62,10 +62,6 @@ typedef enum {
|
||||
GPU_BLEND_INV_DEST_ALPHA
|
||||
} gpu_blending_factor_t;
|
||||
|
||||
typedef enum {
|
||||
GPU_BLENDOP_ADD
|
||||
} gpu_blending_operation_t;
|
||||
|
||||
typedef enum gpu_cull_mode {
|
||||
GPU_CULL_MODE_CLOCKWISE,
|
||||
GPU_CULL_MODE_COUNTERCLOCKWISE,
|
||||
@@ -118,10 +114,8 @@ typedef struct gpu_pipeline {
|
||||
gpu_compare_mode_t depth_mode;
|
||||
gpu_blending_factor_t blend_source;
|
||||
gpu_blending_factor_t blend_destination;
|
||||
gpu_blending_operation_t blend_operation;
|
||||
gpu_blending_factor_t alpha_blend_source;
|
||||
gpu_blending_factor_t alpha_blend_destination;
|
||||
gpu_blending_operation_t alpha_blend_operation;
|
||||
bool color_write_mask_red[8];
|
||||
bool color_write_mask_green[8];
|
||||
bool color_write_mask_blue[8];
|
||||
|
||||
@@ -575,10 +575,8 @@ type shader_context_t = {
|
||||
shader_from_source?: bool; // Build shader at runtime using from_source()
|
||||
blend_source?: string;
|
||||
blend_destination?: string;
|
||||
blend_operation?: string;
|
||||
alpha_blend_source?: string;
|
||||
alpha_blend_destination?: string;
|
||||
alpha_blend_operation?: string;
|
||||
color_writes_red?: bool[]; // Per target masks
|
||||
color_writes_green?: bool[];
|
||||
color_writes_blue?: bool[];
|
||||
|
||||
@@ -33,10 +33,8 @@ function node_shader_context_create(material: material_t, props: shader_context_
|
||||
cull_mode: props.cull_mode,
|
||||
blend_source: props.blend_source,
|
||||
blend_destination: props.blend_destination,
|
||||
blend_operation: props.blend_operation,
|
||||
alpha_blend_source: props.alpha_blend_source,
|
||||
alpha_blend_destination: props.alpha_blend_destination,
|
||||
alpha_blend_operation: props.alpha_blend_operation,
|
||||
fragment_shader: "",
|
||||
vertex_shader: "",
|
||||
vertex_elements: props.vertex_elements != null ? props.vertex_elements : vertex_elements_default,
|
||||
|
||||
@@ -204,10 +204,8 @@ function util_clone_shader_contexts(contexts: shader_context_t[]): shader_contex
|
||||
c.shader_from_source = contexts[i].shader_from_source;
|
||||
c.blend_source = contexts[i].blend_source;
|
||||
c.blend_destination = contexts[i].blend_destination;
|
||||
c.blend_operation = contexts[i].blend_operation;
|
||||
c.alpha_blend_source = contexts[i].alpha_blend_source;
|
||||
c.alpha_blend_destination = contexts[i].alpha_blend_destination;
|
||||
c.alpha_blend_operation = contexts[i].alpha_blend_operation;
|
||||
c.color_writes_red = util_clone_bool_array(contexts[i].color_writes_red);
|
||||
c.color_writes_green = util_clone_bool_array(contexts[i].color_writes_green);
|
||||
c.color_writes_blue = util_clone_bool_array(contexts[i].color_writes_blue);
|
||||
|
||||
Reference in New Issue
Block a user