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

wined3d: Pass device to shader_set_function().

parent 11fc530a
......@@ -928,7 +928,7 @@ static HRESULT shader_record_shader_phase(struct wined3d_shader *shader,
if (shader->reg_maps.shader_version.type != WINED3D_SHADER_TYPE_HULL)
{
ERR("Unexpected shader type %#x.\n", shader->reg_maps.shader_version.type);
ERR("Unexpected shader type %s.\n", debug_shader_type(shader->reg_maps.shader_version.type));
return E_FAIL;
}
......@@ -3321,17 +3321,38 @@ const struct wined3d_shader_backend_ops none_shader_backend =
shader_none_has_ffp_proj_control,
};
static HRESULT shader_set_function(struct wined3d_shader *shader,
unsigned int float_const_count, enum wined3d_shader_type type, unsigned int max_version)
static unsigned int shader_max_version_from_feature_level(enum wined3d_feature_level level)
{
switch (level)
{
case WINED3D_FEATURE_LEVEL_11_1:
case WINED3D_FEATURE_LEVEL_11:
return 5;
case WINED3D_FEATURE_LEVEL_10_1:
case WINED3D_FEATURE_LEVEL_10:
return 4;
case WINED3D_FEATURE_LEVEL_9_SM3:
return 3;
case WINED3D_FEATURE_LEVEL_9_SM2:
case WINED3D_FEATURE_LEVEL_9_1:
return 2;
default:
return 1;
}
}
static HRESULT shader_set_function(struct wined3d_shader *shader, struct wined3d_device *device,
enum wined3d_shader_type type, unsigned int float_const_count)
{
const struct wined3d_d3d_info *d3d_info = &shader->device->adapter->d3d_info;
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
const struct wined3d_shader_version *version = &reg_maps->shader_version;
const struct wined3d_shader_frontend *fe;
unsigned int backend_version;
HRESULT hr;
TRACE("shader %p, float_const_count %u, type %#x, max_version %u.\n",
shader, float_const_count, type, max_version);
TRACE("shader %p, device %p, type %s, float_const_count %u.\n",
shader, device, debug_shader_type(type), float_const_count);
fe = shader->frontend;
if (!(shader->frontend_data = fe->shader_init(shader->function,
......@@ -3349,14 +3370,14 @@ static HRESULT shader_set_function(struct wined3d_shader *shader,
if (FAILED(hr = shader_get_registers_used(shader, float_const_count)))
return hr;
if (reg_maps->shader_version.type != type)
if (version->type != type)
{
WARN("Wrong shader type %#x.\n", reg_maps->shader_version.type);
WARN("Wrong shader type %s.\n", debug_shader_type(reg_maps->shader_version.type));
return WINED3DERR_INVALIDCALL;
}
if (reg_maps->shader_version.major > max_version)
if (version->major > shader_max_version_from_feature_level(device->feature_level))
{
WARN("Shader version %u not supported by this device.\n", reg_maps->shader_version.major);
WARN("Shader version %u not supported by this device.\n", version->major);
return WINED3DERR_INVALIDCALL;
}
switch (type)
......@@ -3383,10 +3404,10 @@ static HRESULT shader_set_function(struct wined3d_shader *shader,
FIXME("No backend version-checking for this shader type.\n");
backend_version = 0;
}
if (reg_maps->shader_version.major > backend_version)
if (version->major > backend_version)
{
WARN("Shader version %d.%d not supported by your GPU with the current shader backend.\n",
reg_maps->shader_version.major, reg_maps->shader_version.minor);
WARN("Shader version %u.%u not supported by the current shader backend.\n",
version->major, version->minor);
return WINED3DERR_INVALIDCALL;
}
......@@ -3638,26 +3659,6 @@ static HRESULT shader_signature_copy(struct wined3d_shader_signature *dst,
return WINED3D_OK;
}
static unsigned int shader_max_version_from_feature_level(enum wined3d_feature_level level)
{
switch (level)
{
case WINED3D_FEATURE_LEVEL_11_1:
case WINED3D_FEATURE_LEVEL_11:
return 5;
case WINED3D_FEATURE_LEVEL_10_1:
case WINED3D_FEATURE_LEVEL_10:
return 4;
case WINED3D_FEATURE_LEVEL_9_SM3:
return 3;
case WINED3D_FEATURE_LEVEL_9_SM2:
case WINED3D_FEATURE_LEVEL_9_1:
return 2;
default:
return 1;
}
}
static HRESULT shader_copy_signatures_from_shader_desc(struct wined3d_shader *shader,
const struct wined3d_shader_desc *desc)
{
......@@ -3702,15 +3703,12 @@ static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device
const struct wined3d_shader_desc *desc, DWORD float_const_count, enum wined3d_shader_type type,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
unsigned int max_version;
size_t byte_code_size;
HRESULT hr;
TRACE("byte_code %p, byte_code_size %#lx, format %#x.\n",
desc->byte_code, (long)desc->byte_code_size, desc->format);
max_version = shader_max_version_from_feature_level(device->feature_level);
if (!(shader->frontend = shader_select_frontend(desc->format)))
{
FIXME("Unable to find frontend for shader.\n");
......@@ -3768,7 +3766,7 @@ static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device
memcpy(shader->function, desc->byte_code, byte_code_size);
shader->functionLength = byte_code_size;
if (FAILED(hr = shader_set_function(shader, float_const_count, type, max_version)))
if (FAILED(hr = shader_set_function(shader, device, type, float_const_count)))
{
WARN("Failed to set function, hr %#x.\n", hr);
shader_cleanup(shader);
......
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