3086{
3104 bool have_attachment, is_dsv_format_unknown;
3108 unsigned int instance_divisor;
3111 size_t rt_count;
3115
3116 static const DWORD default_ps_code[] =
3117 {
3118#if 0
3119 ps_4_0
3121#endif
3122 0x43425844, 0x19cbf606, 0x18f562b9, 0xdaeed4db, 0xc324aa46, 0x00000001, 0x00000060, 0x00000003,
3123 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
3124 0x00000008, 0x00000000, 0x00000008, 0x52444853, 0x0000000c, 0x00000040, 0x00000003, 0x0100003e,
3125 };
3127 static const struct
3128 {
3131 }
3132 shader_stages[] =
3133 {
3139 };
3140
3142 state->refcount = 1;
3143
3146
3147 memset(&input_signature, 0,
sizeof(input_signature));
3148
3150 {
3152 {
3153 WARN(
"Format must be set to DXGI_FORMAT_UNKNOWN for inactive render targets.\n");
3155 }
3156 }
3157
3159 {
3160 WARN(
"Root signature is NULL.\n");
3162 }
3163
3165 if (
desc->sample_desc.Count != 1 &&
desc->sample_desc.Quality)
3166 WARN(
"Ignoring sample quality %u.\n",
desc->sample_desc.Quality);
3167
3168 rt_count =
desc->rtv_formats.NumRenderTargets;
3170 {
3171 FIXME(
"NumRenderTargets %zu > %zu, ignoring extra formats.\n",
3174 }
3175
3177 &&
device->feature_options.OutputMergerLogicOp;
3182 WARN(
"The device does not support output merger logic ops. Ignoring logic op %#x.\n",
3183 desc->blend_state.RenderTarget[0].LogicOp);
3184
3186 for (
i = 0;
i < rt_count; ++
i)
3187 {
3189
3191 {
3195 }
3197 {
3200 }
3201 else
3202 {
3203 WARN(
"Invalid RTV format %#x.\n",
desc->rtv_formats.RTFormats[
i]);
3205 goto fail;
3206 }
3207
3208 rt_desc = &
desc->blend_state.RenderTarget[
desc->blend_state.IndependentBlendEnable ?
i : 0];
3210 {
3211 WARN(
"IndependentBlendEnable must be FALSE when logic operations are enabled.\n");
3213 goto fail;
3214 }
3216 {
3217 WARN(
"Only one of BlendEnable or LogicOpEnable can be set to TRUE.\n");
3219 goto fail;
3220 }
3221
3223 }
3227
3230 {
3231 WARN(
"Depth bounds test not supported by device.\n");
3233 goto fail;
3234 }
3238 {
3239 TRACE(
"Disabling depth test.\n");
3241 }
3242
3246 {
3248 {
3249 WARN(
"DSV format is DXGI_FORMAT_UNKNOWN.\n");
3252 }
3254 {
3256 FIXME(
"Format %#x is not depth/stencil format.\n",
format->dxgi_format);
3257
3259 }
3260 else
3261 {
3262 WARN(
"Invalid DSV format %#x.\n",
desc->dsv_format);
3264 goto fail;
3265 }
3266
3267 if (!
desc->ps.pShaderBytecode)
3268 {
3271 goto fail;
3272
3274 }
3275 }
3276
3280 ps_shader_parameters[0].u.immediate_constant.u.u32 = sample_count;
3281
3283 ps_target_info.next =
NULL;
3284 ps_target_info.entry_point = "main";
3285 ps_target_info.environment =
device->environment;
3288 ps_target_info.parameters = ps_shader_parameters;
3289 ps_target_info.parameter_count =
ARRAY_SIZE(ps_shader_parameters);
3291 ps_target_info.output_swizzles = ps_output_swizzle;
3292 ps_target_info.output_swizzle_count = rt_count;
3293
3294 if (ps_target_info.dual_source_blending && rt_count > 1)
3295 {
3296 WARN(
"Only one render target is allowed when dual source blending is used.\n");
3298 goto fail;
3299 }
3300 if (ps_target_info.dual_source_blending &&
desc->blend_state.IndependentBlendEnable)
3301 {
3303 {
3304 if (
desc->blend_state.RenderTarget[
i].BlendEnable)
3305 {
3306 WARN(
"Blend enable cannot be set for render target %u when dual source blending is used.\n",
i);
3308 goto fail;
3309 }
3310 }
3311 }
3312
3313 memset(&target_info, 0,
sizeof(target_info));
3315 target_info.environment =
device->environment;
3318
3321 {
3323 {
3324 WARN(
"Stream output is used without D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT.\n");
3326 goto fail;
3327 }
3328
3330 {
3331 FIXME(
"Transform feedback is not supported by Vulkan implementation.\n");
3333 goto fail;
3334 }
3335
3337
3339 xfb_info.next =
NULL;
3340
3342 xfb_info.element_count = so_desc->
NumEntries;
3344 xfb_info.buffer_stride_count = so_desc->
NumStrides;
3345
3346 if (
desc->gs.pShaderBytecode)
3348 else if (
desc->ds.pShaderBytecode)
3350 else
3352 }
3353
3355 shader_interface.next =
NULL;
3357 shader_interface.binding_count = root_signature->
binding_count;
3358 shader_interface.push_constant_buffers = root_signature->
root_constants;
3360 shader_interface.combined_samplers =
NULL;
3361 shader_interface.combined_sampler_count = 0;
3362
3364 {
3366 offset_info.next =
NULL;
3371 }
3372
3374 {
3377
3378 if (!
b->pShaderBytecode)
3379 continue;
3380
3382 b, shader_stages[
i].stage)))
3383 goto fail;
3384
3385 shader_interface.uav_counters =
NULL;
3386 shader_interface.uav_counter_count = 0;
3387 stage_target_info = &target_info;
3388 switch (shader_stages[
i].stage)
3389 {
3392 {
3394 goto fail;
3395 }
3396 break;
3397
3401 {
3402 WARN(
"D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH must be used with tessellation shaders.\n");
3404 goto fail;
3405 }
3406 break;
3407
3409 break;
3410
3416 stage_target_info = &ps_target_info;
3417 break;
3418
3419 default:
3421 goto fail;
3422 }
3423
3424 shader_interface.next =
NULL;
3425 xfb_info.next =
NULL;
3426 ps_target_info.next =
NULL;
3427 target_info.next =
NULL;
3428 offset_info.next =
NULL;
3429 if (shader_stages[
i].stage == xfb_stage)
3434
3436 shader_stages[
i].
stage,
b, &shader_interface)))
3437 goto fail;
3438
3440 }
3441
3444 {
3445 FIXME(
"InputLayout.NumElements %zu > %zu, ignoring extra elements.\n",
3448 }
3449
3452 {
3453 WARN(
"Input layout is used without D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT.\n");
3455 goto fail;
3456 }
3457
3459 goto fail;
3460
3463 {
3466
3467
3468
3470 {
3471 WARN(
"Invalid input element format %#x.\n",
e->Format);
3473 goto fail;
3474 }
3475
3478 {
3479 WARN(
"Invalid input slot %#x.\n",
e->InputSlot);
3481 goto fail;
3482 }
3483
3485 e->SemanticName,
e->SemanticIndex, 0)))
3486 {
3487 WARN(
"Unused input element %u.\n",
i);
3488 continue;
3489 }
3490
3496 else
3499
3500 switch (
e->InputSlotClass)
3501 {
3504 instance_divisor = 1;
3505 break;
3506
3509 instance_divisor =
e->InstanceDataStepRate;
3512 {
3513 FIXME(
"Instance divisor %u not supported by Vulkan implementation.\n", instance_divisor);
3514 instance_divisor = 1;
3515 }
3516 break;
3517
3518 default:
3519 FIXME(
"Unhandled input slot class %#x on input element %u.\n",
e->InputSlotClass,
i);
3521 goto fail;
3522 }
3523
3524 if (
mask & (1u <<
e->InputSlot) && (graphics->
input_rates[
e->InputSlot] != input_rate
3525 || instance_divisors[
e->InputSlot] != instance_divisor))
3526 {
3527 FIXME(
"Input slot rate %#x, instance divisor %u on input element %u conflicts "
3528 "with earlier input slot rate %#x, instance divisor %u.\n",
3529 input_rate, instance_divisor,
e->InputSlot,
3530 graphics->
input_rates[
e->InputSlot], instance_divisors[
e->InputSlot]);
3532 goto fail;
3533 }
3534
3536 instance_divisors[
e->InputSlot] = instance_divisor;
3537 if (instance_divisor != 1 && !(
mask & (1u <<
e->InputSlot)))
3538 {
3540 binding_divisor->
binding =
e->InputSlot;
3541 binding_divisor->
divisor = instance_divisor;
3542 }
3543 mask |= 1u <<
e->InputSlot;
3544 }
3547
3548 switch (
desc->strip_cut_value)
3549 {
3554 break;
3555 default:
3556 WARN(
"Invalid index buffer strip cut value %#x.\n",
desc->strip_cut_value);
3558 goto fail;
3559 }
3560
3562
3564 have_attachment = graphics->
rt_count || graphics->
dsv_format || is_dsv_format_unknown;
3565 if ((!have_attachment && !(
desc->ps.pShaderBytecode &&
desc->ps.BytecodeLength))
3568
3572
3580 if (
desc->sample_mask != ~0
u)
3581 {
3586 }
3589
3590 if (
desc->view_instancing_desc.ViewInstanceCount)
3591 {
3592 FIXME(
"View instancing is not supported yet.\n");
3594 goto fail;
3595 }
3596
3597
3598
3599 if (is_dsv_format_unknown)
3603 goto fail;
3604
3606
3608
3610 goto fail;
3611
3615
3617
3618fail:
3620 {
3622 }
3624
3626
3628}
static void list_init(struct list_entry *head)
@ D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA
@ D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA
const UINT D3D12_SO_NO_RASTERIZED_STREAM
@ D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH
@ D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT
@ D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT
const UINT D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
#define offsetof(TYPE, MEMBER)
VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc)
static void ds_desc_from_d3d12(struct VkPipelineDepthStencilStateCreateInfo *vk_desc, const D3D12_DEPTH_STENCIL_DESC1 *d3d12_desc)
static unsigned int vkd3d_get_rt_format_swizzle(const struct vkd3d_format *format)
static bool is_dual_source_blending(const D3D12_RENDER_TARGET_BLEND_DESC *desc)
static void blend_attachment_from_d3d12(struct VkPipelineColorBlendAttachmentState *vk_desc, const D3D12_RENDER_TARGET_BLEND_DESC *d3d12_desc)
static void rs_desc_from_d3d12(VkPipelineRasterizationStateCreateInfo *vk_desc, const D3D12_RASTERIZER_DESC *d3d12_desc)
static VkLogicOp vk_logic_op_from_d3d12(D3D12_LOGIC_OP op)
static HRESULT compute_input_layout_offsets(const struct d3d12_device *device, const D3D12_INPUT_LAYOUT_DESC *input_layout_desc, uint32_t *offsets)
static void rs_stream_info_from_d3d12(VkPipelineRasterizationStateStreamCreateInfoEXT *stream_info, VkPipelineRasterizationStateCreateInfo *vk_rs_desc, const D3D12_STREAM_OUTPUT_DESC *so_desc, const struct vkd3d_vulkan_info *vk_info)
static HRESULT create_shader_stage(struct d3d12_device *device, struct VkPipelineShaderStageCreateInfo *stage_desc, enum VkShaderStageFlagBits stage, const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface)
static void rs_depth_clip_info_from_d3d12(VkPipelineRasterizationDepthClipStateCreateInfoEXT *depth_clip_info, VkPipelineRasterizationStateCreateInfo *vk_rs_desc, const D3D12_RASTERIZER_DESC *d3d12_desc)
const D3D12_SO_DECLARATION_ENTRY * pSODeclaration
const UINT * pBufferStrides
VkCompareOp depthCompareOp
VkBool32 depthBoundsTestEnable
VkPipelineMultisampleStateCreateFlags flags
VkBool32 sampleShadingEnable
VkBool32 alphaToOneEnable
const VkSampleMask * pSampleMask
VkBool32 alphaToCoverageEnable
VkBool32 rasterizerDiscardEnable
VkSampleMask sample_mask[2]
VkPipelineRasterizationDepthClipStateCreateInfoEXT rs_depth_clip_info
VkPipelineRasterizationStateStreamCreateInfoEXT rs_stream_info
D3D12_ROOT_SIGNATURE_FLAGS flags
unsigned int register_index
bool vertex_attrib_zero_divisor
bool EXT_transform_feedback
unsigned int shader_extension_count
enum vkd3d_shader_spirv_extension shader_extensions[VKD3D_MAX_SHADER_EXTENSIONS]
unsigned int max_vertex_attrib_divisor
bool EXT_depth_clip_enable
#define DIV_ROUND_UP(a, b)
VKD3D_SHADER_API struct vkd3d_shader_signature_element * vkd3d_shader_find_signature_element(const struct vkd3d_shader_signature *signature, const char *semantic_name, unsigned int semantic_index, unsigned int stream_index)
@ VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT
@ VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32
VKD3D_SHADER_API int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_signature *signature, char **messages)
VKD3D_SHADER_API void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature)
@ VKD3D_SHADER_STRUCTURE_TYPE_TRANSFORM_FEEDBACK_INFO
#define VKD3D_SHADER_NO_SWIZZLE
@ VKD3D_SHADER_PARAMETER_NAME_RASTERIZER_SAMPLE_COUNT
@ VK_SHADER_STAGE_VERTEX_BIT
@ VK_SHADER_STAGE_GEOMETRY_BIT
@ VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
@ VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
@ VK_SHADER_STAGE_FRAGMENT_BIT
@ VK_IMAGE_ASPECT_STENCIL_BIT
@ VK_IMAGE_ASPECT_DEPTH_BIT
@ VK_VERTEX_INPUT_RATE_VERTEX
@ VK_VERTEX_INPUT_RATE_INSTANCE
@ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO