IDxcLinker doesn't copy the module data layout, so reflection of linked StructuredBuffer elements misplaces 64-bit integer members
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza en lib/HLSL/DxilLinker.cpp, en los dos puntos de creación de módulos nuevos que establecen la triple de destino, y compara la configuración del módulo enlazado con la del módulo original. Lee lib/HLSL/DxilContainerReflection.cpp para ver cómo se obtienen los desplazamientos de los miembros de las estructuras; luego ejecuta la reproducción independiente adjunta y compara la reflexión de la biblioteca con la del módulo enlazado. El objetivo se cumple cuando la reflexión del módulo enlazado informa de un tamaño de 16 y desplazamientos de miembros de 0 y 8 para WithU64, coincidiendo con la biblioteca.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
DxilLinker creates the linked module and copies only the target triple, never the data layout (lib/HLSL/DxilLinker.cpp, the two "Create new module" / setTargetTriple sites). Reflection of a non-cbuffer struct reads member offsets from Module::getDataLayout().getStructLayout() (lib/HLSL/DxilContainerReflection.cpp). On a linked module that falls back to LLVM's default layout, where i64 is 4-byte aligned. A uint64_t member of a StructuredBuffer element therefore moves from offset 8 to 4, and the element size shrinks from 16 to 12.
double is unaffected, because f64:64 is also in LLVM's default layout. The generated code is correct either way; only the reflection is wrong, and an application that sizes or fills buffers from reflection will get it wrong.
Related: the linker also drops other module state, see #5197 (resource type annotations), #5703 (RDAT) and the cbuffer reflection issue I'm filing alongside this one.
Steps to Reproduce
Full standalone repro attached (repro_linker_datalayout.cpp).
- Compile with
-T lib_6_3 -Zi -Qembed_debug(-Zikeeps the member types; the element size is wrong without it too):
struct WithU64 { float a; uint64_t b; };
struct WithF64 { float a; double b; };
StructuredBuffer<WithU64> sbU64;
StructuredBuffer<WithF64> sbF64;
RWByteAddressBuffer o;
[shader("compute")]
[numthreads(1, 1, 1)]
void main(uint id : SV_DispatchThreadID) { o.Store<uint>(0, (uint) sbU64[id].b + (uint) sbF64[id].b); }
IDxcLinker::RegisterLibrary(L"lib", lib), thenLink(L"main", L"cs_6_3", ...).- Reflect the library (
ID3D12LibraryReflection) and the linked shader (ID3D12ShaderReflection). For each buffer, compareD3D12_SHADER_BUFFER_DESC.Sizeand the element type's member offsets.
Actual Behavior
Expected for both buffers: element size 16, a at 0, b at 8
lib sbU64 element size 16, members at a@0 b@8
linked sbU64 element size 12, members at a@0 b@4
lib sbF64 element size 16, members at a@0 b@8
linked sbF64 element size 16, members at a@0 b@8
Environment
- DXC version: <latest release, from
dxc --version>; also reproduces on main, libdxcompiler.so: 1.11(5563-75fba619)(1.10.0.15563) - Host Operating System: Windows (release); Linux x86_64 (main)
- Lenguaje dominante
- C++
- Estrellas
- 3.7k
- Forks
- 914
- Merge medio
- 2 d 20 h
- PR fusionados (30 d)
- 20
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/DirectXShaderCompiler
-
bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/DirectXShaderCompiler#9087 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/DirectXShaderCompiler#9086 ·
Los mantenedores suelen responder en 1 día
-
TimeValue.h fails to compile as C++26 with Clang 22Posiblemente ocupada @reginaldalfret la tomó hace 28 días. Abiertobug needs-triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
microsoft/DirectXShaderCompiler#8992 ·
Los mantenedores suelen responder en 1 día
-
bug needs-triage spirv
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/DirectXShaderCompiler#8831 ·
Los mantenedores suelen responder en 1 día
-
bug needs-triage spirv
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
microsoft/DirectXShaderCompiler#8829 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/DirectXShaderCompiler
Issues similares
-
documentation enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
QuantStack/git2cpp#203 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
BaptisteHudyma/Lamp-Da#588 ·
Los mantenedores suelen responder en 1 día
-
bug macOS networking
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
docling-project/docling-parse#448 ·
Los mantenedores suelen responder en 5 días