From: Kristian Høgsberg Kristensen Date: Tue, 28 Jul 2015 23:32:52 +0000 (-0700) Subject: vk/headers: Update to new generated gen headers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fcea3e2d23b7a02f9cc4b58870ac59107bcf0050;p=mesa.git vk/headers: Update to new generated gen headers This update fixes cases where a 48-bit address field was split into two parts: __gen_address_type MemoryAddress; uint32_t MemoryAddressHigh; which cases this pack code to be generated: dw[1] = __gen_combine_address(data, &dw[1], values->MemoryAddress, dw1); dw[2] = __gen_field(values->MemoryAddressHigh, 0, 15) | 0; which breaks for addresses above 4G. This update also fixes arrays of structs in commands and structs, for example, we now have: struct GEN8_BLEND_STATE_ENTRY Entry[8]; and the pack functions now write all dwords in the packet, making valgrind happy. Finally, we would try to pack 64 bits of blend state into a uint32_t - that's also fixed now. --- diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c index 5aeacefddf6..5a36faa29b5 100644 --- a/src/vulkan/anv_pipeline.c +++ b/src/vulkan/anv_pipeline.c @@ -370,7 +370,7 @@ emit_cb_state(struct anv_pipeline *pipeline, [VK_BLEND_OP_MAX] = BLENDFUNCTION_MAX, }; - uint32_t num_dwords = 1 + info->attachmentCount * 2; + uint32_t num_dwords = GEN8_BLEND_STATE_length; pipeline->blend_state = anv_state_pool_alloc(&device->dynamic_state_pool, num_dwords * 4, 64); @@ -378,13 +378,10 @@ emit_cb_state(struct anv_pipeline *pipeline, .AlphaToCoverageEnable = info->alphaToCoverageEnable, }; - uint32_t *state = pipeline->blend_state.map; - GEN8_BLEND_STATE_pack(NULL, state, &blend_state); - for (uint32_t i = 0; i < info->attachmentCount; i++) { const VkPipelineColorBlendAttachmentState *a = &info->pAttachments[i]; - struct GEN8_BLEND_STATE_ENTRY entry = { + blend_state.Entry[i] = (struct GEN8_BLEND_STATE_ENTRY) { .LogicOpEnable = info->logicOpEnable, .LogicOpFunction = vk_to_gen_logic_op[info->logicOp], .ColorBufferBlendEnable = a->blendEnable, @@ -402,10 +399,10 @@ emit_cb_state(struct anv_pipeline *pipeline, .WriteDisableGreen = !(a->channelWriteMask & VK_CHANNEL_G_BIT), .WriteDisableBlue = !(a->channelWriteMask & VK_CHANNEL_B_BIT), }; - - GEN8_BLEND_STATE_ENTRY_pack(NULL, state + i * 2 + 1, &entry); } + GEN8_BLEND_STATE_pack(NULL, pipeline->blend_state.map, &blend_state); + anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_BLEND_STATE_POINTERS, .BlendStatePointer = pipeline->blend_state.offset, .BlendStatePointerValid = true); diff --git a/src/vulkan/gen75_pack.h b/src/vulkan/gen75_pack.h index 9ea8c2bcf65..583c5f25003 100644 --- a/src/vulkan/gen75_pack.h +++ b/src/vulkan/gen75_pack.h @@ -2806,7 +2806,7 @@ struct GEN75_3DSTATE_POLY_STIPPLE_PATTERN { uint32_t _3DCommandOpcode; uint32_t _3DCommandSubOpcode; uint32_t DwordLength; - uint32_t PatternRow; + uint32_t PatternRow[32]; }; static inline void @@ -2823,9 +2823,11 @@ GEN75_3DSTATE_POLY_STIPPLE_PATTERN_pack(__gen_user_data *data, void * restrict d __gen_field(values->DwordLength, 0, 7) | 0; - dw[1] = - __gen_field(values->PatternRow, 0, 31) | - 0; + for (uint32_t i = 0, j = 1; i < 32; i += 1, j++) { + dw[j] = + __gen_field(values->PatternRow[i + 0], 0, 31) | + 0; + } } @@ -5283,7 +5285,7 @@ struct GEN75_MEDIA_OBJECT_PRT { #define Rootthreadqueue 0 #define VFEstateflush 1 uint32_t PRT_FenceType; - uint32_t InlineData; + uint32_t InlineData[12]; }; static inline void @@ -5313,9 +5315,11 @@ GEN75_MEDIA_OBJECT_PRT_pack(__gen_user_data *data, void * restrict dst, dw[3] = 0; - dw[4] = - __gen_field(values->InlineData, 0, 31) | - 0; + for (uint32_t i = 0, j = 4; i < 12; i += 1, j++) { + dw[j] = + __gen_field(values->InlineData[i + 0], 0, 31) | + 0; + } } @@ -7056,9 +7060,6 @@ GEN75_SF_CLIP_VIEWPORT_pack(__gen_user_data *data, void * restrict dst, __gen_float(values->YMaxClipGuardband) | 0; - dw[12] = - 0; - } #define GEN75_BLEND_STATE_length 0x00000002 @@ -7563,7 +7564,6 @@ struct GEN75_RENDER_SURFACE_STATE { __gen_address_type AppendCounterAddress; bool AppendCounterEnable; bool MCSEnable; - uint32_t ReservedMBZ; uint32_t XOffsetforUVPlane; uint32_t YOffsetforUVPlane; #define SCS_ZERO 0 @@ -7642,7 +7642,6 @@ GEN75_RENDER_SURFACE_STATE_pack(__gen_user_data *data, void * restrict dst, __gen_field(values->MCSSurfacePitch, 3, 11) | __gen_field(values->AppendCounterEnable, 1, 1) | __gen_field(values->MCSEnable, 0, 0) | - __gen_field(values->ReservedMBZ, 30, 31) | __gen_field(values->XOffsetforUVPlane, 16, 29) | __gen_field(values->YOffsetforUVPlane, 0, 13) | 0; @@ -7702,9 +7701,6 @@ GEN75_SAMPLER_BORDER_COLOR_STATE_pack(__gen_user_data *data, void * restrict dst __gen_field(values->BorderColorAlpha, 0, 31) | 0; - dw[4] = - 0; - dw[16] = __gen_field(values->BorderColor, 0, 127) | __gen_field(values->BorderColor, 0, 127) | diff --git a/src/vulkan/gen7_pack.h b/src/vulkan/gen7_pack.h index f9121b78868..05b800034e0 100644 --- a/src/vulkan/gen7_pack.h +++ b/src/vulkan/gen7_pack.h @@ -2156,7 +2156,7 @@ struct GEN7_3DSTATE_POLY_STIPPLE_PATTERN { uint32_t _3DCommandOpcode; uint32_t _3DCommandSubOpcode; uint32_t DwordLength; - uint32_t PatternRow; + uint32_t PatternRow[32]; }; static inline void @@ -2173,9 +2173,11 @@ GEN7_3DSTATE_POLY_STIPPLE_PATTERN_pack(__gen_user_data *data, void * restrict ds __gen_field(values->DwordLength, 0, 7) | 0; - dw[1] = - __gen_field(values->PatternRow, 0, 31) | - 0; + for (uint32_t i = 0, j = 1; i < 32; i += 1, j++) { + dw[j] = + __gen_field(values->PatternRow[i + 0], 0, 31) | + 0; + } } @@ -4451,7 +4453,7 @@ struct GEN7_MEDIA_OBJECT_PRT { #define Rootthreadqueue 0 #define VFEstateflush 1 uint32_t PRT_FenceType; - uint32_t InlineData; + uint32_t InlineData[12]; }; static inline void @@ -4481,9 +4483,11 @@ GEN7_MEDIA_OBJECT_PRT_pack(__gen_user_data *data, void * restrict dst, dw[3] = 0; - dw[4] = - __gen_field(values->InlineData, 0, 31) | - 0; + for (uint32_t i = 0, j = 4; i < 12; i += 1, j++) { + dw[j] = + __gen_field(values->InlineData[i + 0], 0, 31) | + 0; + } } @@ -5812,9 +5816,6 @@ GEN7_SF_CLIP_VIEWPORT_pack(__gen_user_data *data, void * restrict dst, __gen_float(values->YMaxClipGuardband) | 0; - dw[12] = - 0; - } #define GEN7_BLEND_STATE_length 0x00000002 @@ -6288,7 +6289,6 @@ struct GEN7_RENDER_SURFACE_STATE { uint32_t AppendCounterAddress; uint32_t AppendCounterEnable; uint32_t MCSEnable; - uint32_t ReservedMBZ; uint32_t XOffsetforUVPlane; uint32_t YOffsetforUVPlane; #define CC_ZERO 0 @@ -6366,7 +6366,6 @@ GEN7_RENDER_SURFACE_STATE_pack(__gen_user_data *data, void * restrict dst, __gen_field(values->AppendCounterAddress, 6, 31) | __gen_field(values->AppendCounterEnable, 1, 1) | __gen_field(values->MCSEnable, 0, 0) | - __gen_field(values->ReservedMBZ, 30, 31) | __gen_field(values->XOffsetforUVPlane, 16, 29) | __gen_field(values->YOffsetforUVPlane, 0, 13) | 0; diff --git a/src/vulkan/gen8_pack.h b/src/vulkan/gen8_pack.h index dd7f1b55a50..620b5a799c4 100644 --- a/src/vulkan/gen8_pack.h +++ b/src/vulkan/gen8_pack.h @@ -267,7 +267,7 @@ struct GEN8_GPGPU_CSR_BASE_ADDRESS { uint32_t _3DCommandOpcode; uint32_t _3DCommandSubOpcode; uint32_t DwordLength; - __gen_address_type GPGPUCSRBaseAddressHigh; + __gen_address_type GPGPUCSRBaseAddress; }; static inline void @@ -288,7 +288,7 @@ GEN8_GPGPU_CSR_BASE_ADDRESS_pack(__gen_user_data *data, void * restrict dst, 0; uint64_t qw1 = - __gen_combine_address(data, &dw[1], values->GPGPUCSRBaseAddressHigh, dw1); + __gen_combine_address(data, &dw[1], values->GPGPUCSRBaseAddress, dw1); dw[1] = qw1; dw[2] = qw1 >> 32; @@ -319,7 +319,6 @@ struct GEN8_MI_ATOMIC { uint32_t ATOMICOPCODE; uint32_t DwordLength; __gen_address_type MemoryAddress; - uint32_t MemoryAddressHigh; uint32_t Operand1DataDword0; uint32_t Operand2DataDword0; uint32_t Operand1DataDword1; @@ -352,12 +351,11 @@ GEN8_MI_ATOMIC_pack(__gen_user_data *data, void * restrict dst, uint32_t dw1 = 0; - dw[1] = + uint64_t qw1 = __gen_combine_address(data, &dw[1], values->MemoryAddress, dw1); - dw[2] = - __gen_field(values->MemoryAddressHigh, 0, 15) | - 0; + dw[1] = qw1; + dw[2] = qw1 >> 32; dw[3] = __gen_field(values->Operand1DataDword0, 0, 31) | @@ -886,7 +884,6 @@ struct GEN8_SWTESS_BASE_ADDRESS { uint32_t DwordLength; __gen_address_type SWTessellationBaseAddress; struct GEN8_MEMORY_OBJECT_CONTROL_STATE SWTessellationMemoryObjectControlState; - __gen_address_type SWTessellationBaseAddressHigh; }; static inline void @@ -909,14 +906,11 @@ GEN8_SWTESS_BASE_ADDRESS_pack(__gen_user_data *data, void * restrict dst, __gen_field(dw_SWTessellationMemoryObjectControlState, 8, 11) | 0; - dw[1] = + uint64_t qw1 = __gen_combine_address(data, &dw[1], values->SWTessellationBaseAddress, dw1); - uint32_t dw2 = - 0; - - dw[2] = - __gen_combine_address(data, &dw[2], values->SWTessellationBaseAddressHigh, dw2); + dw[1] = qw1; + dw[2] = qw1 >> 32; } @@ -3217,7 +3211,7 @@ struct GEN8_3DSTATE_POLY_STIPPLE_PATTERN { uint32_t _3DCommandOpcode; uint32_t _3DCommandSubOpcode; uint32_t DwordLength; - uint32_t PatternRow; + uint32_t PatternRow[32]; }; static inline void @@ -3234,9 +3228,11 @@ GEN8_3DSTATE_POLY_STIPPLE_PATTERN_pack(__gen_user_data *data, void * restrict ds __gen_field(values->DwordLength, 0, 7) | 0; - dw[1] = - __gen_field(values->PatternRow, 0, 31) | - 0; + for (uint32_t i = 0, j = 1; i < 32; i += 1, j++) { + dw[j] = + __gen_field(values->PatternRow[i + 0], 0, 31) | + 0; + } } @@ -4191,9 +4187,6 @@ GEN8_3DSTATE_SAMPLE_PATTERN_pack(__gen_user_data *data, void * restrict dst, __gen_field(values->DwordLength, 0, 7) | 0; - dw[1] = - 0; - dw[5] = __gen_field(values->_8xSample7XOffset * (1 << 4), 28, 31) | __gen_field(values->_8xSample7YOffset * (1 << 4), 24, 27) | @@ -4363,23 +4356,8 @@ struct GEN8_3DSTATE_SBE_SWIZ { uint32_t _3DCommandOpcode; uint32_t _3DCommandSubOpcode; uint32_t DwordLength; - struct GEN8_SF_OUTPUT_ATTRIBUTE_DETAIL Attribute; - uint32_t Attribute15WrapShortestEnables; - uint32_t Attribute14WrapShortestEnables; - uint32_t Attribute13WrapShortestEnables; - uint32_t Attribute12WrapShortestEnables; - uint32_t Attribute11WrapShortestEnables; - uint32_t Attribute10WrapShortestEnables; - uint32_t Attribute09WrapShortestEnables; - uint32_t Attribute08WrapShortestEnables; - uint32_t Attribute07WrapShortestEnables; - uint32_t Attribute06WrapShortestEnables; - uint32_t Attribute05WrapShortestEnables; - uint32_t Attribute04WrapShortestEnables; - uint32_t Attribute03WrapShortestEnables; - uint32_t Attribute02WrapShortestEnables; - uint32_t Attribute01WrapShortestEnables; - uint32_t Attribute00WrapShortestEnables; + struct GEN8_SF_OUTPUT_ATTRIBUTE_DETAIL Attribute[16]; + uint32_t AttributeWrapShortestEnables[16]; }; static inline void @@ -4396,33 +4374,29 @@ GEN8_3DSTATE_SBE_SWIZ_pack(__gen_user_data *data, void * restrict dst, __gen_field(values->DwordLength, 0, 7) | 0; - uint32_t dw_Attribute; - GEN8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &dw_Attribute, &values->Attribute); - dw[1] = - __gen_field(dw_Attribute, 0, 15) | - 0; - - uint64_t qw9 = - __gen_field(values->Attribute15WrapShortestEnables, 60, 63) | - __gen_field(values->Attribute14WrapShortestEnables, 56, 59) | - __gen_field(values->Attribute13WrapShortestEnables, 52, 55) | - __gen_field(values->Attribute12WrapShortestEnables, 48, 51) | - __gen_field(values->Attribute11WrapShortestEnables, 44, 47) | - __gen_field(values->Attribute10WrapShortestEnables, 40, 43) | - __gen_field(values->Attribute09WrapShortestEnables, 36, 39) | - __gen_field(values->Attribute08WrapShortestEnables, 32, 35) | - __gen_field(values->Attribute07WrapShortestEnables, 28, 31) | - __gen_field(values->Attribute06WrapShortestEnables, 24, 27) | - __gen_field(values->Attribute05WrapShortestEnables, 20, 23) | - __gen_field(values->Attribute04WrapShortestEnables, 16, 19) | - __gen_field(values->Attribute03WrapShortestEnables, 12, 15) | - __gen_field(values->Attribute02WrapShortestEnables, 8, 11) | - __gen_field(values->Attribute01WrapShortestEnables, 4, 7) | - __gen_field(values->Attribute00WrapShortestEnables, 0, 3) | - 0; - - dw[9] = qw9; - dw[10] = qw9 >> 32; + for (uint32_t i = 0, j = 1; i < 16; i += 2, j++) { + uint32_t dw_Attribute0; + GEN8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &dw_Attribute0, &values->Attribute[i + 0]); + uint32_t dw_Attribute1; + GEN8_SF_OUTPUT_ATTRIBUTE_DETAIL_pack(data, &dw_Attribute1, &values->Attribute[i + 1]); + dw[j] = + __gen_field(dw_Attribute0, 0, 15) | + __gen_field(dw_Attribute1, 16, 31) | + 0; + } + + for (uint32_t i = 0, j = 9; i < 16; i += 8, j++) { + dw[j] = + __gen_field(values->AttributeWrapShortestEnables[i + 0], 0, 3) | + __gen_field(values->AttributeWrapShortestEnables[i + 1], 4, 7) | + __gen_field(values->AttributeWrapShortestEnables[i + 2], 8, 11) | + __gen_field(values->AttributeWrapShortestEnables[i + 3], 12, 15) | + __gen_field(values->AttributeWrapShortestEnables[i + 4], 16, 19) | + __gen_field(values->AttributeWrapShortestEnables[i + 5], 20, 23) | + __gen_field(values->AttributeWrapShortestEnables[i + 6], 24, 27) | + __gen_field(values->AttributeWrapShortestEnables[i + 7], 28, 31) | + 0; + } } @@ -6091,7 +6065,7 @@ struct GEN8_MEDIA_OBJECT_GRPID { uint32_t SubSliceDestinationSelect; uint32_t IndirectDataLength; __gen_address_type IndirectDataStartAddress; - uint32_t ScoredboardY; + uint32_t ScoreboardY; uint32_t ScoreboardX; uint32_t ScoreboardColor; bool ScoreboardMask; @@ -6133,7 +6107,7 @@ GEN8_MEDIA_OBJECT_GRPID_pack(__gen_user_data *data, void * restrict dst, __gen_combine_address(data, &dw[3], values->IndirectDataStartAddress, dw3); dw[4] = - __gen_field(values->ScoredboardY, 16, 24) | + __gen_field(values->ScoreboardY, 16, 24) | __gen_field(values->ScoreboardX, 0, 8) | 0; @@ -6170,7 +6144,7 @@ struct GEN8_MEDIA_OBJECT_PRT { #define Rootthreadqueue 0 #define VFEstateflush 1 uint32_t PRT_FenceType; - uint32_t InlineData; + uint32_t InlineData[12]; }; static inline void @@ -6200,9 +6174,11 @@ GEN8_MEDIA_OBJECT_PRT_pack(__gen_user_data *data, void * restrict dst, dw[3] = 0; - dw[4] = - __gen_field(values->InlineData, 0, 31) | - 0; + for (uint32_t i = 0, j = 4; i < 12; i += 1, j++) { + dw[j] = + __gen_field(values->InlineData[i + 0], 0, 31) | + 0; + } } @@ -6587,7 +6563,6 @@ struct GEN8_MI_BATCH_BUFFER_START { uint32_t AddressSpaceIndicator; uint32_t DwordLength; __gen_address_type BatchBufferStartAddress; - __gen_address_type BatchBufferStartAddressHigh; }; static inline void @@ -6610,14 +6585,11 @@ GEN8_MI_BATCH_BUFFER_START_pack(__gen_user_data *data, void * restrict dst, uint32_t dw1 = 0; - dw[1] = + uint64_t qw1 = __gen_combine_address(data, &dw[1], values->BatchBufferStartAddress, dw1); - uint32_t dw2 = - 0; - - dw[2] = - __gen_combine_address(data, &dw[2], values->BatchBufferStartAddressHigh, dw2); + dw[1] = qw1; + dw[2] = qw1 >> 32; } @@ -6635,7 +6607,6 @@ struct GEN8_MI_CLFLUSH { uint32_t DwordLength; __gen_address_type PageBaseAddress; uint32_t StartingCachelineOffset; - __gen_address_type PageBaseAddressHigh; /* variable length fields follow */ }; @@ -6656,14 +6627,11 @@ GEN8_MI_CLFLUSH_pack(__gen_user_data *data, void * restrict dst, __gen_field(values->StartingCachelineOffset, 6, 11) | 0; - dw[1] = + uint64_t qw1 = __gen_combine_address(data, &dw[1], values->PageBaseAddress, dw1); - uint32_t dw2 = - 0; - - dw[2] = - __gen_combine_address(data, &dw[2], values->PageBaseAddressHigh, dw2); + dw[1] = qw1; + dw[2] = qw1 >> 32; /* variable length fields follow */ } @@ -6685,7 +6653,6 @@ struct GEN8_MI_CONDITIONAL_BATCH_BUFFER_END { uint32_t DwordLength; uint32_t CompareDataDword; __gen_address_type CompareAddress; - __gen_address_type CompareAddressHigh; }; static inline void @@ -6709,14 +6676,11 @@ GEN8_MI_CONDITIONAL_BATCH_BUFFER_END_pack(__gen_user_data *data, void * restrict uint32_t dw2 = 0; - dw[2] = + uint64_t qw2 = __gen_combine_address(data, &dw[2], values->CompareAddress, dw2); - uint32_t dw3 = - 0; - - dw[3] = - __gen_combine_address(data, &dw[3], values->CompareAddressHigh, dw3); + dw[2] = qw2; + dw[3] = qw2 >> 32; } @@ -7704,7 +7668,6 @@ struct GEN8_PIPE_CONTROL { #define FlushEnabled 1 bool DepthCacheFlushEnable; __gen_address_type Address; - __gen_address_type AddressHigh; uint64_t ImmediateData; }; @@ -7749,14 +7712,11 @@ GEN8_PIPE_CONTROL_pack(__gen_user_data *data, void * restrict dst, uint32_t dw2 = 0; - dw[2] = + uint64_t qw2 = __gen_combine_address(data, &dw[2], values->Address, dw2); - uint32_t dw3 = - 0; - - dw[3] = - __gen_combine_address(data, &dw[3], values->AddressHigh, dw3); + dw[2] = qw2; + dw[3] = qw2 >> 32; uint64_t qw4 = __gen_field(values->ImmediateData, 0, 63) | @@ -7930,7 +7890,7 @@ GEN8_BLEND_STATE_ENTRY_pack(__gen_user_data *data, void * restrict dst, { uint32_t *dw = (uint32_t * restrict) dst; - dw[0] = + uint64_t qw0 = __gen_field(values->LogicOpEnable, 63, 63) | __gen_field(values->LogicOpFunction, 59, 62) | __gen_field(values->PreBlendSourceOnlyClampEnable, 36, 36) | @@ -7950,6 +7910,9 @@ GEN8_BLEND_STATE_ENTRY_pack(__gen_user_data *data, void * restrict dst, __gen_field(values->WriteDisableBlue, 0, 0) | 0; + dw[0] = qw0; + dw[1] = qw0 >> 32; + } struct GEN8_BLEND_STATE { @@ -7962,7 +7925,7 @@ struct GEN8_BLEND_STATE { bool ColorDitherEnable; uint32_t XDitherOffset; uint32_t YDitherOffset; - struct GEN8_BLEND_STATE_ENTRY Entry; + struct GEN8_BLEND_STATE_ENTRY Entry[8]; }; static inline void @@ -7983,10 +7946,11 @@ GEN8_BLEND_STATE_pack(__gen_user_data *data, void * restrict dst, __gen_field(values->YDitherOffset, 19, 20) | 0; - GEN8_BLEND_STATE_ENTRY_pack(data, &dw[1], &values->Entry); + for (uint32_t i = 0, j = 1; i < 8; i++, j += 2) + GEN8_BLEND_STATE_ENTRY_pack(data, &dw[j], &values->Entry[i]); } -#define GEN8_BLEND_STATE_ENTRY_length 0x00000001 +#define GEN8_BLEND_STATE_ENTRY_length 0x00000002 #define GEN8_CC_VIEWPORT_length 0x00000002