Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/directx.c | 2 ++ dlls/wined3d/glsl_shader.c | 13 +++++++++++-- dlls/wined3d/shader.c | 6 ++++++ dlls/wined3d/wined3d_gl.h | 1 + dlls/wined3d/wined3d_private.h | 3 ++- 5 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index e0bf98604428..5058740464a2 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -119,6 +119,7 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH }, {"GL_ARB_copy_buffer", ARB_COPY_BUFFER }, {"GL_ARB_copy_image", ARB_COPY_IMAGE }, + {"GL_ARB_cull_distance", ARB_CULL_DISTANCE }, {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT }, {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT }, {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE }, @@ -3916,6 +3917,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, {ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)},
{ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)}, + {ARB_CULL_DISTANCE, MAKEDWORD_VERSION(4, 5)}, {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)},
{ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index b89b7aa3d53c..976c7cdb6213 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -6930,8 +6930,10 @@ static void shader_glsl_generate_clip_or_cull_distances(struct wined3d_string_bu const struct wined3d_shader_signature_element *element, DWORD clip_or_cull_distance_mask) { unsigned int i, clip_or_cull_index; + const char *name; char reg_mask[6];
+ name = element->sysval_semantic == WINED3D_SV_CLIP_DISTANCE ? "Clip" : "Cull"; /* Assign consecutive indices starting from 0. */ clip_or_cull_index = element->semantic_idx ? wined3d_popcount(clip_or_cull_distance_mask & 0xf) : 0; for (i = 0; i < 4; ++i) @@ -6940,8 +6942,8 @@ static void shader_glsl_generate_clip_or_cull_distances(struct wined3d_string_bu continue;
shader_glsl_write_mask_to_str(WINED3DSP_WRITEMASK_0 << i, reg_mask); - shader_addline(buffer, "gl_ClipDistance[%u] = outputs[%u]%s;\n", - clip_or_cull_index, element->register_idx, reg_mask); + shader_addline(buffer, "gl_%sDistance[%u] = outputs[%u]%s;\n", + name, clip_or_cull_index, element->register_idx, reg_mask); ++clip_or_cull_index; } } @@ -6993,6 +6995,10 @@ static void shader_glsl_setup_sm3_rasterizer_input(struct shader_glsl_priv *priv { shader_glsl_generate_clip_or_cull_distances(buffer, output, reg_maps_out->clip_distance_mask); } + else if (output->sysval_semantic == WINED3D_SV_CULL_DISTANCE) + { + shader_glsl_generate_clip_or_cull_distances(buffer, output, reg_maps_out->cull_distance_mask); + } else if (output->sysval_semantic) { FIXME("Unhandled sysval semantic %#x.\n", output->sysval_semantic); @@ -7393,6 +7399,8 @@ static void shader_glsl_generate_alpha_test(struct wined3d_string_buffer *buffer static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info) { + if (gl_info->supported[ARB_CULL_DISTANCE]) + shader_addline(buffer, "#extension GL_ARB_cull_distance : enable\n"); if (gl_info->supported[ARB_GPU_SHADER5]) shader_addline(buffer, "#extension GL_ARB_gpu_shader5 : enable\n"); if (gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS]) @@ -10875,6 +10883,7 @@ static unsigned int shader_glsl_get_shader_model(const struct wined3d_gl_info *g
if (shader_model_4 && gl_info->supported[ARB_COMPUTE_SHADER] + && gl_info->supported[ARB_CULL_DISTANCE] && gl_info->supported[ARB_DERIVATIVE_CONTROL] && gl_info->supported[ARB_DRAW_INDIRECT] && gl_info->supported[ARB_GPU_SHADER5] diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 7d59f8b9a042..d9765731abb1 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1789,6 +1789,12 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st return hr; reg_maps->clip_distance_mask |= mask; } + else if (e->sysval_semantic == WINED3D_SV_CULL_DISTANCE) + { + if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask))) + return hr; + reg_maps->cull_distance_mask |= mask; + } } } else if (reg_maps->output_registers) diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 455f4154a2a8..0894c946db83 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -52,6 +52,7 @@ enum wined3d_gl_extension ARB_CONSERVATIVE_DEPTH, ARB_COPY_BUFFER, ARB_COPY_IMAGE, + ARB_CULL_DISTANCE, ARB_DEBUG_OUTPUT, ARB_DEPTH_BUFFER_FLOAT, ARB_DEPTH_TEXTURE, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b8f0b4d194e0..6f1328084b84 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1010,6 +1010,7 @@ struct wined3d_shader_reg_maps DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */ + DWORD cull_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */ DWORD usesnrm : 1; DWORD vpos : 1; DWORD usesdsx : 1; @@ -1025,7 +1026,7 @@ struct wined3d_shader_reg_maps DWORD usespow : 1; DWORD point_size : 1; DWORD vocp : 1; - DWORD padding : 25; + DWORD padding : 17;
DWORD rt_mask; /* Used render targets, 32 max. */