Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 20 ++++++++++++++++++-- dlls/d3d10/tests/effect.c | 24 +++++++++++++++--------- 2 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index e121ad9cac2..12cfb457399 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -5794,6 +5794,11 @@ static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_
/* ID3D10EffectVariable methods */
+static inline struct d3d10_effect_variable *impl_from_ID3D10EffectStringVariable(ID3D10EffectStringVariable *iface) +{ + return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface); +} + static BOOL STDMETHODCALLTYPE d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable *iface) { TRACE("iface %p\n", iface); @@ -5950,9 +5955,20 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetRawValue(ID3D10 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable *iface, const char **str) { - FIXME("iface %p, str %p stub!\n", iface, str); + struct d3d10_effect_variable *var = impl_from_ID3D10EffectStringVariable(iface); + char *value = (char *)var->u.buffer.local_buffer;
- return E_NOTIMPL; + TRACE("iface %p, str %p.\n", iface, str); + + if (!value) + return E_FAIL; + + if (!str) + return E_INVALIDARG; + + *str = value; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable *iface, diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 871bf78cc27..cae16491993 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -1423,22 +1423,28 @@ static void test_effect_variable_type_class(void) ok(td.Stride == 0x0, "Stride is %#x, expected 0x0\n", td.Stride);
string_var = variable->lpVtbl->AsString(variable); + hr = string_var->lpVtbl->GetString(string_var, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); hr = string_var->lpVtbl->GetString(string_var, &str1); -todo_wine ok(SUCCEEDED(hr), "GetString failed %#x.\n", hr); - if (SUCCEEDED(hr)) - ok(!strcmp(str1, "STRING"), "Unexpected value %s.\n", str1); + ok(!strcmp(str1, "STRING"), "Unexpected value %s.\n", str1);
variable = constantbuffer->lpVtbl->GetAnnotationByIndex(constantbuffer, 1); string_var = variable->lpVtbl->AsString(variable); hr = string_var->lpVtbl->GetString(string_var, &str2); -todo_wine ok(SUCCEEDED(hr), "GetString failed %#x.\n", hr); - if (SUCCEEDED(hr)) - { - ok(str2 != str1, "Unexpected string pointer.\n"); - ok(!strcmp(str2, "STRING"), "Unexpected value %s.\n", str1); - } + ok(str2 != str1, "Unexpected string pointer.\n"); + ok(!strcmp(str2, "STRING"), "Unexpected value %s.\n", str1); + + /* Only two annotations */ + variable = constantbuffer->lpVtbl->GetAnnotationByIndex(constantbuffer, 2); + string_var = variable->lpVtbl->AsString(variable); + hr = string_var->lpVtbl->GetString(string_var, NULL); + ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr); + str1 = (void *)0xdeadbeef; + hr = string_var->lpVtbl->GetString(string_var, &str1); + ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr); + ok(str1 == (void *)0xdeadbeef, "Unexpected pointer.\n");
/* check float f */ variable = constantbuffer->lpVtbl->GetMemberByIndex(constantbuffer, variable_nr++);