Skip to content

Commit cd93deb

Browse files
jdolanclaude
andcommitted
GraphicsPipeline: export preset data symbols from the Windows DLL
The GPU_BlendState* and GPU_GraphicsPipeline* presets are the only exported global *data* in the library (everything else is functions or Class descriptors). clang-cl propagates __declspec(dllexport) from a prior declaration to a function definition, but not to a variable definition, so these consts were compiled into ObjectivelyGPU.dll without export records and were absent from the import library. That broke downstream links on Windows (e.g. Quetoo's renderer): lld-link : error : undefined symbol: GPU_BlendStateOpaque lld-link : error : undefined symbol: GPU_GraphicsPipeline3D ... Add an OBJECTIVELYGPU_EXPORT_DATA macro (dllexport/dllimport on the Windows DLL build, empty elsewhere) and apply it to the preset definitions so the symbols are exported. Using a dedicated data macro rather than OBJECTIVELYGPU_EXPORT (which is `extern`) also avoids a -Wextern-initializer warning on the autotools/Linux build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d49e2cd commit cd93deb

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

ObjectivelyGPU.vs15/Sources/WindowlyGPU.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
#ifdef BUILDING_OBJECTIVELYGPU
2727
#define OBJECTIVELYGPU_EXPORT extern __declspec(dllexport)
28+
#define OBJECTIVELYGPU_EXPORT_DATA __declspec(dllexport)
2829
#else
2930
#define OBJECTIVELYGPU_EXPORT __declspec(dllimport)
31+
#define OBJECTIVELYGPU_EXPORT_DATA __declspec(dllimport)
3032
#endif

Sources/ObjectivelyGPU/GraphicsPipeline.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030

3131
#pragma mark - Presets
3232

33-
const SDL_GPUColorTargetBlendState GPU_BlendStateOpaque = {
33+
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUColorTargetBlendState GPU_BlendStateOpaque = {
3434
.enable_blend = false,
3535
};
3636

37-
const SDL_GPUColorTargetBlendState GPU_BlendStateAlpha = {
37+
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUColorTargetBlendState GPU_BlendStateAlpha = {
3838
.enable_blend = true,
3939
.src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA,
4040
.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
@@ -44,7 +44,7 @@ const SDL_GPUColorTargetBlendState GPU_BlendStateAlpha = {
4444
.alpha_blend_op = SDL_GPU_BLENDOP_ADD,
4545
};
4646

47-
const SDL_GPUColorTargetBlendState GPU_BlendStatePremultipliedAlpha = {
47+
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUColorTargetBlendState GPU_BlendStatePremultipliedAlpha = {
4848
.enable_blend = true,
4949
.src_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE,
5050
.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
@@ -54,7 +54,7 @@ const SDL_GPUColorTargetBlendState GPU_BlendStatePremultipliedAlpha = {
5454
.alpha_blend_op = SDL_GPU_BLENDOP_ADD,
5555
};
5656

57-
const SDL_GPUColorTargetBlendState GPU_BlendStateAdditive = {
57+
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUColorTargetBlendState GPU_BlendStateAdditive = {
5858
.enable_blend = true,
5959
.src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA,
6060
.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE,
@@ -64,7 +64,7 @@ const SDL_GPUColorTargetBlendState GPU_BlendStateAdditive = {
6464
.alpha_blend_op = SDL_GPU_BLENDOP_ADD,
6565
};
6666

67-
const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline3D = {
67+
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline3D = {
6868
.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
6969
.rasterizer_state = {
7070
.fill_mode = SDL_GPU_FILLMODE_FILL,
@@ -82,7 +82,7 @@ const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline3D = {
8282
},
8383
};
8484

85-
const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline2D = {
85+
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline2D = {
8686
.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
8787
.rasterizer_state = {
8888
.fill_mode = SDL_GPU_FILLMODE_FILL,

Sources/ObjectivelyGPU/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#define OBJECTIVELYGPU_EXPORT extern
3636
#endif
3737

38+
#ifndef OBJECTIVELYGPU_EXPORT_DATA
39+
#define OBJECTIVELYGPU_EXPORT_DATA
40+
#endif
41+
3842
typedef struct SDL_Size SDL_Size;
3943

4044
/**

0 commit comments

Comments
 (0)