8012{
8014 {{{
8015 -11.0f, -12.0f, 0.0f, 0.0f,
8016 -21.0f, -22.0f, 0.0f, 0.0f,
8017 -31.0f, -32.0f, 0.0f, 0.0f,
8018 }}};
8020 {{{
8021 11.0f, 12.0f, 0.0f, 0.0f,
8022 21.0f, 22.0f, 0.0f, 0.0f,
8023 31.0f, 32.0f, 0.0f, 0.0f,
8024 }}};
8026 static const float float_array_zero[4];
8027 IDirect3DTexture9 *
texture, *tex_test;
8029 ID3DXEffect *effect, *effect2;
8031 IDirect3DDevice9 *
device;
8032 ID3DXEffectPool *
pool;
8033 float float_array[4];
8034 float float_value;
8035 IDirect3D9 *d3d;
8039
8042 {
8043 skip(
"Failed to create window.\n");
8044 return;
8045 }
8047 {
8048 skip(
"Failed to create IDirect3D9 object.\n");
8050 return;
8051 }
8057 {
8058 skip(
"Failed to create IDirect3DDevice9 object, hr %#x.\n",
hr);
8061 return;
8062 }
8063
8066
8073
8074 hr = effect->lpVtbl->BeginParameterBlock(effect);
8076 hr = effect->lpVtbl->BeginParameterBlock(effect);
8078 block = effect->lpVtbl->EndParameterBlock(effect);
8080 handle = effect->lpVtbl->EndParameterBlock(effect);
8082
8083
8084 effect->lpVtbl->AddRef(effect);
8085 refcount = effect->lpVtbl->Release(effect);
8086 ok(refcount == 1,
"Got unexpected refcount %u.\n", refcount);
8087
8088 hr = effect->lpVtbl->ApplyParameterBlock(effect,
block);
8090 hr = effect->lpVtbl->DeleteParameterBlock(effect,
block);
8092
8093 hr = effect->lpVtbl->BeginParameterBlock(effect);
8095 hr = effect->lpVtbl->SetFloat(effect,
"vec3[0]", 1001.0f);
8097 hr = effect->lpVtbl->SetFloat(effect,
"arr1[0]", 91.0f);
8099 block = effect->lpVtbl->EndParameterBlock(effect);
8101 hr = effect->lpVtbl->ApplyParameterBlock(effect,
block);
8103
8104 hr = effect->lpVtbl->DeleteParameterBlock(effect2,
block);
8106 hr = effect->lpVtbl->DeleteParameterBlock(effect,
block);
8108
8109 hr = effect->lpVtbl->ApplyParameterBlock(effect,
NULL);
8111 hr = effect->lpVtbl->ApplyParameterBlock(effect,
"parameter_block");
8113
8115 ok(
hr ==
D3D_OK,
"Got result %#x, expected 0 (D3D_OK).\n",
hr);
8116
8117 hr = effect->lpVtbl->BeginParameterBlock(effect);
8119
8120
8121 hr = effect->lpVtbl->SetTexture(effect,
"tex1", (IDirect3DBaseTexture9 *)
texture);
8123
8124 hr = effect->lpVtbl->GetTexture(effect,
"tex1", (IDirect3DBaseTexture9 **)&tex_test);
8125 ok(
hr ==
D3D_OK && !tex_test,
"Got unexpected hr %#x, tex_test %p.\n",
hr, tex_test);
8126
8127
8128
8129 hr = effect->lpVtbl->SetFloat(effect,
"arr2[0]", 92.0f);
8131 hr = effect->lpVtbl->SetFloat(effect,
"ts1[0].fv", 28.0f);
8133 hr = effect->lpVtbl->GetFloat(effect,
"ts1[0].fv", &float_value);
8134 ok(
hr ==
D3D_OK && float_value == 12.0,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8135
8136 float_array[0] = -29.0f;
8137 hr = effect->lpVtbl->SetFloatArray(effect,
"ts1[0].v2", float_array, 1);
8139 hr = effect->lpVtbl->GetFloatArray(effect,
"ts1[0].v2", float_array, 1);
8140 ok(
hr ==
D3D_OK && float_array[0] == 13.0,
"Got unexpected hr %#x, float_array[0] %g.\n",
8141 hr, float_array[0]);
8142
8144 hr = effect->lpVtbl->SetMatrix(effect,
"m3x2row", &test_mat);
8146 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2row", &
mat);
8148 ok(!
memcmp(&
mat, &effect_orig_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8149
8150 hr = effect->lpVtbl->SetMatrix(effect,
"m3x2column", &test_mat);
8152 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2column", &
mat);
8154 ok(!
memcmp(&
mat, &effect_orig_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8155
8156
8157
8158 hr = effect2->lpVtbl->SetFloat(effect2,
"arr2[1]", -1.0f);
8160 hr = effect->lpVtbl->GetFloat(effect,
"arr2[1]", &float_value);
8161 ok(float_value == -1.0f,
"Unexpected value %g.\n", float_value);
8162
8165 ok(refcount == 2,
"Got unexpected refcount %u.\n", refcount);
8166
8167 block = effect->lpVtbl->EndParameterBlock(effect);
8169
8172 ok(refcount == 2,
"Got unexpected refcount %u.\n", refcount);
8173
8174 hr = effect->lpVtbl->DeleteParameterBlock(effect2,
block);
8176
8179 ok(refcount == 2,
"Got unexpected refcount %u.\n", refcount);
8180
8181 hr = effect->lpVtbl->SetFloat(effect,
"arr2[0]", 0.0f);
8183 hr = effect->lpVtbl->SetFloat(effect,
"arr2[1]", 0.0f);
8185 hr = effect->lpVtbl->SetFloatArray(effect,
"ts1[0].v1", float_array_zero, 3);
8187 hr = effect->lpVtbl->SetFloat(effect,
"ts1[0].fv", 0.0f);
8189 hr = effect->lpVtbl->SetFloatArray(effect,
"ts1[0].v2", float_array_zero, 4);
8192 hr = effect->lpVtbl->SetMatrix(effect,
"m3x2row", &
mat);
8194 hr = effect->lpVtbl->SetMatrix(effect,
"m3x2column", &
mat);
8196
8197 hr = effect->lpVtbl->ApplyParameterBlock(effect,
block);
8199
8202 ok(refcount == 3,
"Got unexpected refcount %u.\n", refcount);
8203
8204 hr = effect->lpVtbl->GetFloat(effect,
"arr2[0]", &float_value);
8205 ok(
hr ==
D3D_OK && float_value == 92.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8206 hr = effect->lpVtbl->GetFloat(effect,
"arr2[1]", &float_value);
8207 ok(
hr ==
D3D_OK && float_value == 0.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8208
8209 hr = effect->lpVtbl->GetFloatArray(effect,
"ts1[0].v1", float_array, 3);
8210 ok(
hr ==
D3D_OK && !
memcmp(float_array, float_array_zero, 3 *
sizeof(*float_array)),
8211 "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n",
hr,
8212 float_array[0], float_array[1], float_array[2]);
8213
8214 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2row", &
mat);
8216 ok(!
memcmp(&
mat, &test_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8217 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2column", &
mat);
8219 ok(!
memcmp(&
mat, &test_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8220
8221 hr = effect->lpVtbl->GetFloat(effect,
"ts1[0].fv", &float_value);
8222 ok(
hr ==
D3D_OK && float_value == 28.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8223
8224 hr = effect->lpVtbl->GetFloatArray(effect,
"ts1[0].v2", float_array, 4);
8226 && !
memcmp(float_array + 1, float_array_zero, 3 *
sizeof(*float_array)),
8227 "Got unexpected hr %#x, ts1[0].v2 (%g, %g, %g, %g).\n",
hr,
8228 float_array[0], float_array[1], float_array[2], float_array[3]);
8229
8230
8231 hr = effect->lpVtbl->SetFloat(effect,
"arr2[0]", 0.0f);
8233 hr = effect->lpVtbl->SetFloat(effect,
"arr2[1]", 0.0f);
8235 hr = effect->lpVtbl->SetFloatArray(effect,
"ts1[0].v1", float_array_zero, 3);
8237 hr = effect->lpVtbl->SetFloat(effect,
"ts1[0].fv", 0.0f);
8239 hr = effect->lpVtbl->SetFloatArray(effect,
"ts1[0].v2", float_array_zero, 4);
8242 hr = effect->lpVtbl->SetMatrix(effect,
"m3x2row", &effect_orig_mat);
8244 hr = effect->lpVtbl->SetMatrix(effect,
"m3x2column", &effect_orig_mat);
8246
8247 hr = effect->lpVtbl->BeginParameterBlock(effect);
8249 hr = effect->lpVtbl->ApplyParameterBlock(effect,
block);
8251
8252 hr = effect->lpVtbl->GetFloat(effect,
"arr2[0]", &float_value);
8253 ok(
hr ==
D3D_OK && float_value == 0.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8254 hr = effect->lpVtbl->GetFloat(effect,
"arr2[1]", &float_value);
8255 ok(
hr ==
D3D_OK && float_value == 0.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8256
8257 hr = effect->lpVtbl->GetFloatArray(effect,
"ts1[0].v1", float_array, 3);
8258 ok(
hr ==
D3D_OK && !
memcmp(float_array, float_array_zero, 3 *
sizeof(*float_array)),
8259 "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n",
hr,
8260 float_array[0], float_array[1], float_array[2]);
8261
8262 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2row", &
mat);
8264 ok(!
memcmp(&
mat, &effect_orig_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8265 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2column", &
mat);
8267 ok(!
memcmp(&
mat, &effect_orig_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8268
8269 hr = effect->lpVtbl->GetFloat(effect,
"ts1[0].fv", &float_value);
8270 ok(
hr ==
D3D_OK && float_value == 0.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8271
8272 hr = effect->lpVtbl->GetFloatArray(effect,
"ts1[0].v2", float_array, 4);
8274 && !
memcmp(float_array + 1, float_array_zero, 3 *
sizeof(*float_array)),
8275 "Got unexpected hr %#x, ts1[0].v2 (%g, %g, %g, %g).\n",
hr,
8276 float_array[0], float_array[1], float_array[2], float_array[3]);
8277
8278 block2 = effect->lpVtbl->EndParameterBlock(effect);
8280
8281 hr = effect->lpVtbl->ApplyParameterBlock(effect,
block2);
8283
8284 hr = effect->lpVtbl->GetFloat(effect,
"arr2[0]", &float_value);
8285 ok(
hr ==
D3D_OK && float_value == 92.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8286 hr = effect->lpVtbl->GetFloat(effect,
"arr2[1]", &float_value);
8287 ok(
hr ==
D3D_OK && float_value == 0.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8288
8289 hr = effect->lpVtbl->GetFloatArray(effect,
"ts1[0].v1", float_array, 3);
8290 ok(
hr ==
D3D_OK && !
memcmp(float_array, float_array_zero, 3 *
sizeof(*float_array)),
8291 "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n",
hr,
8292 float_array[0], float_array[1], float_array[2]);
8293
8294 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2row", &
mat);
8296 ok(!
memcmp(&
mat, &test_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8297 hr = effect->lpVtbl->GetMatrix(effect,
"m3x2column", &
mat);
8299 ok(!
memcmp(&
mat, &test_mat,
sizeof(
mat)),
"Got unexpected matrix.\n");
8300
8301 hr = effect->lpVtbl->GetFloat(effect,
"ts1[0].fv", &float_value);
8302 ok(
hr ==
D3D_OK && float_value == 28.0f,
"Got unexpected hr %#x, float_value %g.\n",
hr, float_value);
8303
8304 hr = effect->lpVtbl->GetFloatArray(effect,
"ts1[0].v2", float_array, 4);
8306 && !
memcmp(float_array + 1, float_array_zero, 3 *
sizeof(*float_array)),
8307 "Got unexpected hr %#x, ts1[0].v2 (%g, %g, %g, %g).\n",
hr,
8308 float_array[0], float_array[1], float_array[2], float_array[3]);
8309
8310 hr = effect->lpVtbl->DeleteParameterBlock(effect,
block);
8312 hr = effect->lpVtbl->DeleteParameterBlock(effect,
block2);
8314
8315 hr = effect->lpVtbl->SetTexture(effect,
"tex1",
NULL);
8318 ok(!refcount,
"Got unexpected refcount %u.\n", refcount);
8319
8320 refcount = effect->lpVtbl->Release(effect);
8321 ok(!refcount,
"Got unexpected refcount %u.\n", refcount);
8322
8323 refcount = effect2->lpVtbl->Release(effect2);
8324 ok(!refcount,
"Got unexpected refcount %u.\n", refcount);
8325
8326 refcount =
pool->lpVtbl->Release(
pool);
8327 ok(!refcount,
"Got unexpected refcount %u.\n", refcount);
8328
8331 hr = effect->lpVtbl->BeginParameterBlock(effect);
8333 mat_arr[0] = mat_arr[1] = test_mat;
8334 hr = effect->lpVtbl->SetMatrixArray(effect,
"f33_2", mat_arr, 2);
8336 block = effect->lpVtbl->EndParameterBlock(effect);
8338
8339 memset(mat_arr, 0,
sizeof(mat_arr));
8340 hr = effect->lpVtbl->SetMatrixArray(effect,
"f33_2", mat_arr, 2);
8342 hr = effect->lpVtbl->ApplyParameterBlock(effect,
block);
8344
8345 hr = effect->lpVtbl->GetMatrixArray(effect,
"f33_2", mat_arr, 2);
8347 ok(!
memcmp(&mat_arr[0], &test_mat,
sizeof(test_mat))
8348 && !
memcmp(&mat_arr[1], &test_mat,
sizeof(test_mat)),
"Got unexpected matrix array.\n");
8349
8350 refcount = effect->lpVtbl->Release(effect);
8351 ok(!refcount,
"Got unexpected refcount %u.\n", refcount);
8352
8354 ok(!refcount,
"Device has %u references left.\n", refcount);
8357}
HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
static const DWORD test_effect_parameter_value_blob_float[]
static unsigned int block