Commit 429e0c91 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Implement SV_CullDistance.

parent 75c703b4
...@@ -119,6 +119,7 @@ static const struct wined3d_extension_map gl_extension_map[] = ...@@ -119,6 +119,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH }, {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH },
{"GL_ARB_copy_buffer", ARB_COPY_BUFFER }, {"GL_ARB_copy_buffer", ARB_COPY_BUFFER },
{"GL_ARB_copy_image", ARB_COPY_IMAGE }, {"GL_ARB_copy_image", ARB_COPY_IMAGE },
{"GL_ARB_cull_distance", ARB_CULL_DISTANCE },
{"GL_ARB_debug_output", ARB_DEBUG_OUTPUT }, {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
{"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT }, {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
{"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE }, {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
...@@ -3916,6 +3917,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, ...@@ -3916,6 +3917,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
{ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)}, {ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)},
{ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)}, {ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)},
{ARB_CULL_DISTANCE, MAKEDWORD_VERSION(4, 5)},
{ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)}, {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)},
{ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)}, {ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)},
......
...@@ -6930,8 +6930,10 @@ static void shader_glsl_generate_clip_or_cull_distances(struct wined3d_string_bu ...@@ -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) const struct wined3d_shader_signature_element *element, DWORD clip_or_cull_distance_mask)
{ {
unsigned int i, clip_or_cull_index; unsigned int i, clip_or_cull_index;
const char *name;
char reg_mask[6]; char reg_mask[6];
name = element->sysval_semantic == WINED3D_SV_CLIP_DISTANCE ? "Clip" : "Cull";
/* Assign consecutive indices starting from 0. */ /* Assign consecutive indices starting from 0. */
clip_or_cull_index = element->semantic_idx ? wined3d_popcount(clip_or_cull_distance_mask & 0xf) : 0; clip_or_cull_index = element->semantic_idx ? wined3d_popcount(clip_or_cull_distance_mask & 0xf) : 0;
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
...@@ -6940,8 +6942,8 @@ static void shader_glsl_generate_clip_or_cull_distances(struct wined3d_string_bu ...@@ -6940,8 +6942,8 @@ static void shader_glsl_generate_clip_or_cull_distances(struct wined3d_string_bu
continue; continue;
shader_glsl_write_mask_to_str(WINED3DSP_WRITEMASK_0 << i, reg_mask); shader_glsl_write_mask_to_str(WINED3DSP_WRITEMASK_0 << i, reg_mask);
shader_addline(buffer, "gl_ClipDistance[%u] = outputs[%u]%s;\n", shader_addline(buffer, "gl_%sDistance[%u] = outputs[%u]%s;\n",
clip_or_cull_index, element->register_idx, reg_mask); name, clip_or_cull_index, element->register_idx, reg_mask);
++clip_or_cull_index; ++clip_or_cull_index;
} }
} }
...@@ -6993,6 +6995,10 @@ static void shader_glsl_setup_sm3_rasterizer_input(struct shader_glsl_priv *priv ...@@ -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); 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) else if (output->sysval_semantic)
{ {
FIXME("Unhandled sysval semantic %#x.\n", 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 ...@@ -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, static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer,
const struct wined3d_gl_info *gl_info) 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]) if (gl_info->supported[ARB_GPU_SHADER5])
shader_addline(buffer, "#extension GL_ARB_gpu_shader5 : enable\n"); shader_addline(buffer, "#extension GL_ARB_gpu_shader5 : enable\n");
if (gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS]) 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 ...@@ -10875,6 +10883,7 @@ static unsigned int shader_glsl_get_shader_model(const struct wined3d_gl_info *g
if (shader_model_4 if (shader_model_4
&& gl_info->supported[ARB_COMPUTE_SHADER] && gl_info->supported[ARB_COMPUTE_SHADER]
&& gl_info->supported[ARB_CULL_DISTANCE]
&& gl_info->supported[ARB_DERIVATIVE_CONTROL] && gl_info->supported[ARB_DERIVATIVE_CONTROL]
&& gl_info->supported[ARB_DRAW_INDIRECT] && gl_info->supported[ARB_DRAW_INDIRECT]
&& gl_info->supported[ARB_GPU_SHADER5] && gl_info->supported[ARB_GPU_SHADER5]
......
...@@ -1789,6 +1789,12 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st ...@@ -1789,6 +1789,12 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
return hr; return hr;
reg_maps->clip_distance_mask |= mask; 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) else if (reg_maps->output_registers)
......
...@@ -52,6 +52,7 @@ enum wined3d_gl_extension ...@@ -52,6 +52,7 @@ enum wined3d_gl_extension
ARB_CONSERVATIVE_DEPTH, ARB_CONSERVATIVE_DEPTH,
ARB_COPY_BUFFER, ARB_COPY_BUFFER,
ARB_COPY_IMAGE, ARB_COPY_IMAGE,
ARB_CULL_DISTANCE,
ARB_DEBUG_OUTPUT, ARB_DEBUG_OUTPUT,
ARB_DEPTH_BUFFER_FLOAT, ARB_DEPTH_BUFFER_FLOAT,
ARB_DEPTH_TEXTURE, ARB_DEPTH_TEXTURE,
......
...@@ -1010,6 +1010,7 @@ struct wined3d_shader_reg_maps ...@@ -1010,6 +1010,7 @@ struct wined3d_shader_reg_maps
DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */ DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */ DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
DWORD cull_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
DWORD usesnrm : 1; DWORD usesnrm : 1;
DWORD vpos : 1; DWORD vpos : 1;
DWORD usesdsx : 1; DWORD usesdsx : 1;
...@@ -1025,7 +1026,7 @@ struct wined3d_shader_reg_maps ...@@ -1025,7 +1026,7 @@ struct wined3d_shader_reg_maps
DWORD usespow : 1; DWORD usespow : 1;
DWORD point_size : 1; DWORD point_size : 1;
DWORD vocp : 1; DWORD vocp : 1;
DWORD padding : 25; DWORD padding : 17;
DWORD rt_mask; /* Used render targets, 32 max. */ DWORD rt_mask; /* Used render targets, 32 max. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment