Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
fce60001
Commit
fce60001
authored
Apr 03, 2018
by
Sven Hesse
Committed by
Alexandre Julliard
Apr 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d11: Create wined3d textures for 1D textures.
Signed-off-by:
Henri Verbeet
<
hverbeet@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0e9f94ec
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1155 additions
and
9 deletions
+1155
-9
device.c
dlls/d3d10core/tests/device.c
+528
-2
d3d11_private.h
dlls/d3d11/d3d11_private.h
+3
-0
d3d11.c
dlls/d3d11/tests/d3d11.c
+532
-2
texture.c
dlls/d3d11/texture.c
+84
-5
utils.c
dlls/d3d11/utils.c
+8
-0
No files found.
dlls/d3d10core/tests/device.c
View file @
fce60001
...
@@ -1313,6 +1313,7 @@ static void test_device_interfaces(void)
...
@@ -1313,6 +1313,7 @@ static void test_device_interfaces(void)
static
void
test_create_texture1d
(
void
)
static
void
test_create_texture1d
(
void
)
{
{
ULONG
refcount
,
expected_refcount
;
ULONG
refcount
,
expected_refcount
;
D3D10_SUBRESOURCE_DATA
data
=
{
0
};
ID3D10Device
*
device
,
*
tmp
;
ID3D10Device
*
device
,
*
tmp
;
D3D10_TEXTURE1D_DESC
desc
;
D3D10_TEXTURE1D_DESC
desc
;
ID3D10Texture1D
*
texture
;
ID3D10Texture1D
*
texture
;
...
@@ -1334,6 +1335,9 @@ static void test_create_texture1d(void)
...
@@ -1334,6 +1335,9 @@ static void test_create_texture1d(void)
desc
.
CPUAccessFlags
=
0
;
desc
.
CPUAccessFlags
=
0
;
desc
.
MiscFlags
=
0
;
desc
.
MiscFlags
=
0
;
hr
=
ID3D10Device_CreateTexture1D
(
device
,
&
desc
,
&
data
,
&
texture
);
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#x.
\n
"
,
hr
);
expected_refcount
=
get_refcount
(
device
)
+
1
;
expected_refcount
=
get_refcount
(
device
)
+
1
;
hr
=
ID3D10Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
&
texture
);
hr
=
ID3D10Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 1d texture, hr %#x.
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 1d texture, hr %#x.
\n
"
,
hr
);
...
@@ -1381,8 +1385,7 @@ static void test_create_texture1d(void)
...
@@ -1381,8 +1385,7 @@ static void test_create_texture1d(void)
desc
.
BindFlags
=
D3D10_BIND_SHADER_RESOURCE
;
desc
.
BindFlags
=
D3D10_BIND_SHADER_RESOURCE
;
desc
.
MiscFlags
=
0
;
desc
.
MiscFlags
=
0
;
hr
=
ID3D10Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
(
ID3D10Texture1D
**
)
&
texture
);
hr
=
ID3D10Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
(
ID3D10Texture1D
**
)
&
texture
);
todo_wine_if
(
!
i
)
ok
(
hr
==
(
i
?
S_OK
:
E_INVALIDARG
),
"Test %u: Got unexpected hr %#x.
\n
"
,
i
,
hr
);
ok
(
hr
==
(
i
?
S_OK
:
E_INVALIDARG
),
"Test %u: Got unexpected hr %#x.
\n
"
,
i
,
hr
);
if
(
SUCCEEDED
(
hr
))
if
(
SUCCEEDED
(
hr
))
ID3D10Texture1D_Release
(
texture
);
ID3D10Texture1D_Release
(
texture
);
}
}
...
@@ -5550,6 +5553,528 @@ done:
...
@@ -5550,6 +5553,528 @@ done:
release_test_context
(
&
test_context
);
release_test_context
(
&
test_context
);
}
}
static
void
test_texture1d
(
void
)
{
struct
shader
{
const
DWORD
*
code
;
size_t
size
;
};
struct
texture
{
UINT
width
;
UINT
miplevel_count
;
UINT
array_size
;
DXGI_FORMAT
format
;
D3D10_SUBRESOURCE_DATA
data
[
3
];
};
struct
d3d10core_test_context
test_context
;
D3D10_SHADER_RESOURCE_VIEW_DESC
srv_desc
;
const
struct
texture
*
current_texture
;
D3D10_TEXTURE1D_DESC
texture_desc
;
D3D10_SAMPLER_DESC
sampler_desc
;
const
struct
shader
*
current_ps
;
ID3D10ShaderResourceView
*
srv
;
ID3D10SamplerState
*
sampler
;
struct
resource_readback
rb
;
ID3D10Texture1D
*
texture
;
struct
vec4
ps_constant
;
ID3D10PixelShader
*
ps
;
ID3D10Device
*
device
;
unsigned
int
i
,
x
;
ID3D10Buffer
*
cb
;
DWORD
color
;
HRESULT
hr
;
static
const
DWORD
ps_ld_code
[]
=
{
#if 0
Texture1D t;
float miplevel;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float2 p;
t.GetDimensions(miplevel, p.x, p.y);
p.y = miplevel;
p *= float2(position.x / 640.0f, 1.0f);
return t.Load(int2(p));
}
#endif
0x43425844
,
0x7b0c6359
,
0x598178f6
,
0xef2ddbdb
,
0x88fc794c
,
0x00000001
,
0x000001ac
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000110
,
0x00000040
,
0x00000044
,
0x04000059
,
0x00208e46
,
0x00000000
,
0x00000001
,
0x04001058
,
0x00107000
,
0x00000000
,
0x00005555
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000001
,
0x0600001c
,
0x00100012
,
0x00000000
,
0x0020800a
,
0x00000000
,
0x00000000
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x0010100a
,
0x00000000
,
0x06000036
,
0x001000e2
,
0x00000000
,
0x00208006
,
0x00000000
,
0x00000000
,
0x0a000038
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3acccccd
,
0x3f800000
,
0x3f800000
,
0x3f800000
,
0x0500001b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0700002d
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x0100003e
,
};
static
const
struct
shader
ps_ld
=
{
ps_ld_code
,
sizeof
(
ps_ld_code
)};
static
const
DWORD
ps_ld_sint8_code
[]
=
{
#if 0
Texture1D<int4> t;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float2 p, s;
int4 c;
p = float2(position.x / 640.0f, 0.0f);
t.GetDimensions(0, s.x, s.y);
p *= s;
c = t.Load(int2(p));
return (max(c / (float4)127, (float4)-1) + (float4)1) / 2.0f;
}
#endif
0x43425844
,
0x65a13d1e
,
0x8a0bfc92
,
0xa2f2708a
,
0x0bafafb6
,
0x00000001
,
0x00000234
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000198
,
0x00000040
,
0x00000066
,
0x04001058
,
0x00107000
,
0x00000000
,
0x00003333
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000002
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x00004001
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000001
,
0x0010100a
,
0x00000000
,
0x00004001
,
0x3acccccd
,
0x08000036
,
0x001000e2
,
0x00000001
,
0x00004002
,
0x00000000
,
0x00000000
,
0x00000000
,
0x00000000
,
0x07000038
,
0x001000f2
,
0x00000000
,
0x00100fc6
,
0x00000000
,
0x00100e46
,
0x00000001
,
0x0500001b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0700002d
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x0500002b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0a000038
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3c010204
,
0x3c010204
,
0x3c010204
,
0x3c010204
,
0x0a000034
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0xbf800000
,
0xbf800000
,
0xbf800000
,
0xbf800000
,
0x0a000000
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3f800000
,
0x3f800000
,
0x3f800000
,
0x3f800000
,
0x0a000038
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3f000000
,
0x3f000000
,
0x3f000000
,
0x3f000000
,
0x0100003e
,
};
static
const
struct
shader
ps_ld_sint8
=
{
ps_ld_sint8_code
,
sizeof
(
ps_ld_sint8_code
)};
static
const
DWORD
ps_ld_uint8_code
[]
=
{
#if 0
Texture1D<uint4> t;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float2 p, s;
p = float2(position.x / 640.0f, 0.0f);
t.GetDimensions(0, s.x, s.y);
p *= s;
return t.Load(int2(p)) / (float4)255;
}
#endif
0x43425844
,
0x35186c1f
,
0x55bad4fd
,
0xb7c97a57
,
0x99c060e7
,
0x00000001
,
0x000001bc
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000120
,
0x00000040
,
0x00000048
,
0x04001058
,
0x00107000
,
0x00000000
,
0x00004444
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000002
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x00004001
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000001
,
0x0010100a
,
0x00000000
,
0x00004001
,
0x3acccccd
,
0x08000036
,
0x001000e2
,
0x00000001
,
0x00004002
,
0x00000000
,
0x00000000
,
0x00000000
,
0x00000000
,
0x07000038
,
0x001000f2
,
0x00000000
,
0x00100fc6
,
0x00000000
,
0x00100e46
,
0x00000001
,
0x0500001b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0700002d
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x05000056
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0a000038
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3b808081
,
0x3b808081
,
0x3b808081
,
0x3b808081
,
0x0100003e
,
};
static
const
struct
shader
ps_ld_uint8
=
{
ps_ld_uint8_code
,
sizeof
(
ps_ld_uint8_code
)};
static
DWORD
ps_ld_array_code
[]
=
{
#if 0
Texture1DArray t;
float miplevel;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float3 p;
t.GetDimensions(miplevel, p.x, p.y, p.z);
p.y = 1;
p.z = miplevel;
p *= float3(position.x / 640.0f, 1.0f, 1.0f);
return t.Load(int3(p));
}
#endif
0x43425844
,
0xbfccadc4
,
0xc00ff13d
,
0x2ba75365
,
0xf747cbee
,
0x00000001
,
0x000001c0
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000124
,
0x00000040
,
0x00000049
,
0x04000059
,
0x00208e46
,
0x00000000
,
0x00000001
,
0x04003858
,
0x00107000
,
0x00000000
,
0x00005555
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000001
,
0x0600001c
,
0x00100012
,
0x00000000
,
0x0020800a
,
0x00000000
,
0x00000000
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x0010100a
,
0x00000000
,
0x06000036
,
0x001000c2
,
0x00000000
,
0x00208006
,
0x00000000
,
0x00000000
,
0x0a000038
,
0x00100072
,
0x00000000
,
0x00100386
,
0x00000000
,
0x00004002
,
0x3acccccd
,
0x3f800000
,
0x3f800000
,
0x00000000
,
0x0500001b
,
0x001000d2
,
0x00000000
,
0x00100906
,
0x00000000
,
0x05000036
,
0x00100022
,
0x00000000
,
0x00004001
,
0x00000001
,
0x0700002d
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x0100003e
,
};
static
const
struct
shader
ps_ld_array
=
{
ps_ld_array_code
,
sizeof
(
ps_ld_array_code
)};
static
const
DWORD
rgba_level_0
[]
=
{
0xff0000ff
,
0xff00ffff
,
0xff00ff00
,
0xffffff00
,
};
static
const
DWORD
rgba_level_1
[]
=
{
0xffffffff
,
0xff0000ff
,
};
static
const
DWORD
rgba_level_2
[]
=
{
0xffff0000
,
};
static
const
DWORD
srgb_data
[]
=
{
0x00000000
,
0xffffffff
,
0xff000000
,
0x7f7f7f7f
,
};
static
const
DWORD
r32_uint
[]
=
{
0
,
1
,
2
,
3
,
};
static
const
DWORD
r9g9b9e5_data
[]
=
{
0x80000100
,
0x80020000
,
0x84000000
,
0x84000100
,
};
static
const
DWORD
array_data0
[]
=
{
0xff0000ff
,
0xff00ffff
,
0xff00ff00
,
0xffffff00
,
};
static
const
DWORD
array_data1
[]
=
{
0x00ffff00
,
0xff000000
,
0x00ff0000
,
0x000000ff
,
};
static
const
DWORD
array_data2
[]
=
{
0x000000ff
,
0xffff00ff
,
0x0000ff00
,
0xff000000
,
};
static
const
struct
texture
rgba_texture
=
{
4
,
3
,
1
,
DXGI_FORMAT_R8G8B8A8_UNORM
,
{
{
rgba_level_0
,
4
*
sizeof
(
*
rgba_level_0
),
0
},
{
rgba_level_1
,
2
*
sizeof
(
*
rgba_level_1
),
0
},
{
rgba_level_2
,
sizeof
(
*
rgba_level_2
),
0
},
}
};
static
const
struct
texture
srgb_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
{{
srgb_data
,
4
*
sizeof
(
*
srgb_data
)}}};
static
const
struct
texture
sint8_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R8G8B8A8_SINT
,
{{
rgba_level_0
,
4
*
sizeof
(
*
rgba_level_0
)}}};
static
const
struct
texture
uint8_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R8G8B8A8_UINT
,
{{
rgba_level_0
,
4
*
sizeof
(
*
rgba_level_0
)}}};
static
const
struct
texture
r32u_typeless
=
{
4
,
1
,
1
,
DXGI_FORMAT_R32_TYPELESS
,
{{
r32_uint
,
4
*
sizeof
(
*
r32_uint
)}}};
static
const
struct
texture
r9g9b9e5_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP
,
{{
r9g9b9e5_data
,
4
*
sizeof
(
*
r9g9b9e5_data
)}}};
static
const
struct
texture
array_texture
=
{
4
,
1
,
3
,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
{
{
array_data0
,
4
*
sizeof
(
*
array_data0
)},
{
array_data1
,
4
*
sizeof
(
*
array_data1
)},
{
array_data2
,
4
*
sizeof
(
*
array_data2
)},
}
};
static
const
DWORD
level_1_colors
[]
=
{
0xffffffff
,
0xffffffff
,
0xff0000ff
,
0xff0000ff
,
};
static
const
DWORD
level_2_colors
[]
=
{
0xffff0000
,
0xffff0000
,
0xffff0000
,
0xffff0000
,
};
static
const
DWORD
srgb_colors
[]
=
{
0x00000001
,
0xffffffff
,
0xff000000
,
0x7f363636
,
};
static
const
DWORD
sint8_colors
[]
=
{
0x7e80807e
,
0x7e807e7e
,
0x7e807e80
,
0x7e7e7e80
,
};
static
const
DWORD
r32u_colors
[
4
]
=
{
0x01000000
,
0x01000001
,
0x01000002
,
0x01000003
,
};
static
const
DWORD
r9g9b9e5_colors
[
4
]
=
{
0xff0000ff
,
0xff00ff00
,
0xffff0000
,
0xffff00ff
,
};
static
const
DWORD
zero_colors
[
4
]
=
{
0
};
static
const
float
red
[]
=
{
1
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
5
f
};
static
const
struct
texture_test
{
const
struct
shader
*
ps
;
const
struct
texture
*
texture
;
D3D10_FILTER
filter
;
float
lod_bias
;
float
min_lod
;
float
max_lod
;
float
ps_constant
;
const
DWORD
*
expected_colors
;
}
texture_tests
[]
=
{
#define POINT D3D10_FILTER_MIN_MAG_MIP_POINT
#define POINT_LINEAR D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR
#define MIP_MAX D3D10_FLOAT32_MAX
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
rgba_level_0
},
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
level_1_colors
},
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
2
.
0
f
,
level_2_colors
},
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
3
.
0
f
,
zero_colors
},
{
&
ps_ld
,
&
srgb_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
srgb_colors
},
{
&
ps_ld
,
&
r9g9b9e5_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
r9g9b9e5_colors
},
{
&
ps_ld
,
NULL
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
zero_colors
},
{
&
ps_ld
,
NULL
,
POINT
,
0
.
0
f
,
0
.
0
f
,
MIP_MAX
,
0
.
0
f
,
zero_colors
},
{
&
ps_ld_sint8
,
&
sint8_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
sint8_colors
},
{
&
ps_ld_uint8
,
&
uint8_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
rgba_level_0
},
{
&
ps_ld_array
,
&
array_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
array_data1
},
};
#undef POINT
#undef POINT_LINEAR
#undef MIP_MAX
static
const
struct
srv_test
{
const
struct
shader
*
ps
;
const
struct
texture
*
texture
;
struct
srv_desc
srv_desc
;
float
ps_constant
;
const
DWORD
*
expected_colors
;
}
srv_tests
[]
=
{
#define TEX_1D D3D10_SRV_DIMENSION_TEXTURE1D
#define R32_UINT DXGI_FORMAT_R32_UINT
{
&
ps_ld_uint8
,
&
r32u_typeless
,
{
R32_UINT
,
TEX_1D
,
0
,
1
},
0
.
0
f
,
r32u_colors
},
#undef TEX_1D
#undef R32_UINT
#undef FMT_UNKNOWN
};
if
(
!
init_test_context
(
&
test_context
))
return
;
device
=
test_context
.
device
;
cb
=
create_buffer
(
device
,
D3D10_BIND_CONSTANT_BUFFER
,
sizeof
(
ps_constant
),
NULL
);
ID3D10Device_PSSetConstantBuffers
(
device
,
0
,
1
,
&
cb
);
texture_desc
.
Usage
=
D3D10_USAGE_DEFAULT
;
texture_desc
.
BindFlags
=
D3D10_BIND_SHADER_RESOURCE
;
texture_desc
.
CPUAccessFlags
=
0
;
texture_desc
.
MiscFlags
=
0
;
sampler_desc
.
Filter
=
D3D10_FILTER_MIN_MAG_MIP_POINT
;
sampler_desc
.
AddressU
=
D3D10_TEXTURE_ADDRESS_CLAMP
;
sampler_desc
.
AddressV
=
D3D10_TEXTURE_ADDRESS_CLAMP
;
sampler_desc
.
AddressW
=
D3D10_TEXTURE_ADDRESS_CLAMP
;
sampler_desc
.
MipLODBias
=
0
.
0
f
;
sampler_desc
.
MaxAnisotropy
=
0
;
sampler_desc
.
ComparisonFunc
=
D3D10_COMPARISON_NEVER
;
sampler_desc
.
BorderColor
[
0
]
=
0
.
0
f
;
sampler_desc
.
BorderColor
[
1
]
=
0
.
0
f
;
sampler_desc
.
BorderColor
[
2
]
=
0
.
0
f
;
sampler_desc
.
BorderColor
[
3
]
=
0
.
0
f
;
sampler_desc
.
MinLOD
=
0
.
0
f
;
sampler_desc
.
MaxLOD
=
D3D10_FLOAT32_MAX
;
ps
=
NULL
;
srv
=
NULL
;
sampler
=
NULL
;
texture
=
NULL
;
current_ps
=
NULL
;
current_texture
=
NULL
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
texture_tests
);
++
i
)
{
const
struct
texture_test
*
test
=
&
texture_tests
[
i
];
if
(
current_ps
!=
test
->
ps
)
{
if
(
ps
)
ID3D10PixelShader_Release
(
ps
);
current_ps
=
test
->
ps
;
hr
=
ID3D10Device_CreatePixelShader
(
device
,
current_ps
->
code
,
current_ps
->
size
,
&
ps
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create pixel shader, hr %#x.
\n
"
,
i
,
hr
);
ID3D10Device_PSSetShader
(
device
,
ps
);
}
if
(
current_texture
!=
test
->
texture
)
{
if
(
texture
)
ID3D10Texture1D_Release
(
texture
);
if
(
srv
)
ID3D10ShaderResourceView_Release
(
srv
);
current_texture
=
test
->
texture
;
if
(
current_texture
)
{
texture_desc
.
Width
=
current_texture
->
width
;
texture_desc
.
MipLevels
=
current_texture
->
miplevel_count
;
texture_desc
.
ArraySize
=
current_texture
->
array_size
;
texture_desc
.
Format
=
current_texture
->
format
;
hr
=
ID3D10Device_CreateTexture1D
(
device
,
&
texture_desc
,
current_texture
->
data
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create 1d texture, hr %#x.
\n
"
,
i
,
hr
);
hr
=
ID3D10Device_CreateShaderResourceView
(
device
,
(
ID3D10Resource
*
)
texture
,
NULL
,
&
srv
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create shader resource view, hr %#x.
\n
"
,
i
,
hr
);
}
else
{
texture
=
NULL
;
srv
=
NULL
;
}
ID3D10Device_PSSetShaderResources
(
device
,
0
,
1
,
&
srv
);
}
if
(
!
sampler
||
(
sampler_desc
.
Filter
!=
test
->
filter
||
sampler_desc
.
MipLODBias
!=
test
->
lod_bias
||
sampler_desc
.
MinLOD
!=
test
->
min_lod
||
sampler_desc
.
MaxLOD
!=
test
->
max_lod
))
{
if
(
sampler
)
ID3D10SamplerState_Release
(
sampler
);
sampler_desc
.
Filter
=
test
->
filter
;
sampler_desc
.
MipLODBias
=
test
->
lod_bias
;
sampler_desc
.
MinLOD
=
test
->
min_lod
;
sampler_desc
.
MaxLOD
=
test
->
max_lod
;
hr
=
ID3D10Device_CreateSamplerState
(
device
,
&
sampler_desc
,
&
sampler
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create sampler state, hr %#x.
\n
"
,
i
,
hr
);
ID3D10Device_PSSetSamplers
(
device
,
0
,
1
,
&
sampler
);
}
ps_constant
.
x
=
test
->
ps_constant
;
ID3D10Device_UpdateSubresource
(
device
,
(
ID3D10Resource
*
)
cb
,
0
,
NULL
,
&
ps_constant
,
0
,
0
);
ID3D10Device_ClearRenderTargetView
(
device
,
test_context
.
backbuffer_rtv
,
red
);
draw_quad
(
&
test_context
);
get_texture_readback
(
test_context
.
backbuffer
,
0
,
&
rb
);
for
(
x
=
0
;
x
<
4
;
++
x
)
{
color
=
get_readback_color
(
&
rb
,
80
+
x
*
160
,
0
);
ok
(
compare_color
(
color
,
test
->
expected_colors
[
x
],
2
),
"Test %u: Got unexpected color 0x%08x at (%u).
\n
"
,
i
,
color
,
x
);
}
release_resource_readback
(
&
rb
);
}
if
(
srv
)
ID3D10ShaderResourceView_Release
(
srv
);
ID3D10SamplerState_Release
(
sampler
);
if
(
texture
)
ID3D10Texture1D_Release
(
texture
);
ID3D10PixelShader_Release
(
ps
);
if
(
is_warp_device
(
device
)
&&
!
is_d3d11_interface_available
(
device
))
{
win_skip
(
"SRV tests are broken on WARP.
\n
"
);
ID3D10Buffer_Release
(
cb
);
release_test_context
(
&
test_context
);
return
;
}
sampler_desc
.
Filter
=
D3D10_FILTER_MIN_MAG_MIP_POINT
;
sampler_desc
.
MipLODBias
=
0
.
0
f
;
sampler_desc
.
MinLOD
=
0
.
0
f
;
sampler_desc
.
MaxLOD
=
D3D10_FLOAT32_MAX
;
hr
=
ID3D10Device_CreateSamplerState
(
device
,
&
sampler_desc
,
&
sampler
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create sampler state, hr %#x.
\n
"
,
hr
);
ID3D10Device_PSSetSamplers
(
device
,
0
,
1
,
&
sampler
);
ps
=
NULL
;
srv
=
NULL
;
texture
=
NULL
;
current_ps
=
NULL
;
current_texture
=
NULL
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
srv_tests
);
++
i
)
{
const
struct
srv_test
*
test
=
&
srv_tests
[
i
];
if
(
current_ps
!=
test
->
ps
)
{
if
(
ps
)
ID3D10PixelShader_Release
(
ps
);
current_ps
=
test
->
ps
;
hr
=
ID3D10Device_CreatePixelShader
(
device
,
current_ps
->
code
,
current_ps
->
size
,
&
ps
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create pixel shader, hr %#x.
\n
"
,
i
,
hr
);
ID3D10Device_PSSetShader
(
device
,
ps
);
}
if
(
current_texture
!=
test
->
texture
)
{
if
(
texture
)
ID3D10Texture1D_Release
(
texture
);
current_texture
=
test
->
texture
;
texture_desc
.
Width
=
current_texture
->
width
;
texture_desc
.
MipLevels
=
current_texture
->
miplevel_count
;
texture_desc
.
ArraySize
=
current_texture
->
array_size
;
texture_desc
.
Format
=
current_texture
->
format
;
hr
=
ID3D10Device_CreateTexture1D
(
device
,
&
texture_desc
,
current_texture
->
data
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create 1d texture, hr %#x.
\n
"
,
i
,
hr
);
}
if
(
srv
)
ID3D10ShaderResourceView_Release
(
srv
);
get_srv_desc
(
&
srv_desc
,
&
test
->
srv_desc
);
hr
=
ID3D10Device_CreateShaderResourceView
(
device
,
(
ID3D10Resource
*
)
texture
,
&
srv_desc
,
&
srv
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create shader resource view, hr %#x.
\n
"
,
i
,
hr
);
ID3D10Device_PSSetShaderResources
(
device
,
0
,
1
,
&
srv
);
ps_constant
.
x
=
test
->
ps_constant
;
ID3D10Device_UpdateSubresource
(
device
,
(
ID3D10Resource
*
)
cb
,
0
,
NULL
,
&
ps_constant
,
0
,
0
);
ID3D10Device_ClearRenderTargetView
(
device
,
test_context
.
backbuffer_rtv
,
red
);
draw_quad
(
&
test_context
);
get_texture_readback
(
test_context
.
backbuffer
,
0
,
&
rb
);
for
(
x
=
0
;
x
<
4
;
++
x
)
{
color
=
get_readback_color
(
&
rb
,
80
+
x
*
160
,
0
);
ok
(
compare_color
(
color
,
test
->
expected_colors
[
x
],
1
),
"Test %u: Got unexpected color 0x%08x at (%u).
\n
"
,
i
,
color
,
x
);
}
release_resource_readback
(
&
rb
);
}
ID3D10PixelShader_Release
(
ps
);
ID3D10Texture1D_Release
(
texture
);
ID3D10ShaderResourceView_Release
(
srv
);
ID3D10SamplerState_Release
(
sampler
);
ID3D10Buffer_Release
(
cb
);
release_test_context
(
&
test_context
);
}
static
void
test_texture
(
void
)
static
void
test_texture
(
void
)
{
{
struct
shader
struct
shader
...
@@ -15040,6 +15565,7 @@ START_TEST(device)
...
@@ -15040,6 +15565,7 @@ START_TEST(device)
test_scissor
();
test_scissor
();
test_clear_state
();
test_clear_state
();
test_blend
();
test_blend
();
test_texture1d
();
test_texture
();
test_texture
();
test_cube_maps
();
test_cube_maps
();
test_depth_stencil_sampling
();
test_depth_stencil_sampling
();
...
...
dlls/d3d11/d3d11_private.h
View file @
fce60001
...
@@ -120,12 +120,15 @@ struct d3d_texture1d
...
@@ -120,12 +120,15 @@ struct d3d_texture1d
LONG
refcount
;
LONG
refcount
;
struct
wined3d_private_store
private_store
;
struct
wined3d_private_store
private_store
;
struct
wined3d_texture
*
wined3d_texture
;
D3D11_TEXTURE1D_DESC
desc
;
D3D11_TEXTURE1D_DESC
desc
;
ID3D11Device
*
device
;
ID3D11Device
*
device
;
};
};
HRESULT
d3d_texture1d_create
(
struct
d3d_device
*
device
,
const
D3D11_TEXTURE1D_DESC
*
desc
,
HRESULT
d3d_texture1d_create
(
struct
d3d_device
*
device
,
const
D3D11_TEXTURE1D_DESC
*
desc
,
const
D3D11_SUBRESOURCE_DATA
*
data
,
struct
d3d_texture1d
**
texture
)
DECLSPEC_HIDDEN
;
const
D3D11_SUBRESOURCE_DATA
*
data
,
struct
d3d_texture1d
**
texture
)
DECLSPEC_HIDDEN
;
struct
d3d_texture1d
*
unsafe_impl_from_ID3D11Texture1D
(
ID3D11Texture1D
*
iface
)
DECLSPEC_HIDDEN
;
struct
d3d_texture1d
*
unsafe_impl_from_ID3D10Texture1D
(
ID3D10Texture1D
*
iface
)
DECLSPEC_HIDDEN
;
/* ID3D11Texture2D, ID3D10Texture2D */
/* ID3D11Texture2D, ID3D10Texture2D */
struct
d3d_texture2d
struct
d3d_texture2d
...
...
dlls/d3d11/tests/d3d11.c
View file @
fce60001
...
@@ -1828,6 +1828,7 @@ static void test_get_immediate_context(void)
...
@@ -1828,6 +1828,7 @@ static void test_get_immediate_context(void)
static
void
test_create_texture1d
(
void
)
static
void
test_create_texture1d
(
void
)
{
{
ULONG
refcount
,
expected_refcount
;
ULONG
refcount
,
expected_refcount
;
D3D11_SUBRESOURCE_DATA
data
=
{
0
};
ID3D11Device
*
device
,
*
tmp
;
ID3D11Device
*
device
,
*
tmp
;
D3D11_TEXTURE1D_DESC
desc
;
D3D11_TEXTURE1D_DESC
desc
;
ID3D11Texture1D
*
texture
;
ID3D11Texture1D
*
texture
;
...
@@ -1849,6 +1850,9 @@ static void test_create_texture1d(void)
...
@@ -1849,6 +1850,9 @@ static void test_create_texture1d(void)
desc
.
CPUAccessFlags
=
0
;
desc
.
CPUAccessFlags
=
0
;
desc
.
MiscFlags
=
0
;
desc
.
MiscFlags
=
0
;
hr
=
ID3D11Device_CreateTexture1D
(
device
,
&
desc
,
&
data
,
&
texture
);
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#x.
\n
"
,
hr
);
expected_refcount
=
get_refcount
(
device
)
+
1
;
expected_refcount
=
get_refcount
(
device
)
+
1
;
hr
=
ID3D11Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
&
texture
);
hr
=
ID3D11Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 1d texture, hr %#x.
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 1d texture, hr %#x.
\n
"
,
hr
);
...
@@ -1906,8 +1910,7 @@ static void test_create_texture1d(void)
...
@@ -1906,8 +1910,7 @@ static void test_create_texture1d(void)
desc
.
BindFlags
=
D3D11_BIND_SHADER_RESOURCE
;
desc
.
BindFlags
=
D3D11_BIND_SHADER_RESOURCE
;
desc
.
MiscFlags
=
0
;
desc
.
MiscFlags
=
0
;
hr
=
ID3D11Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
(
ID3D11Texture1D
**
)
&
texture
);
hr
=
ID3D11Device_CreateTexture1D
(
device
,
&
desc
,
NULL
,
(
ID3D11Texture1D
**
)
&
texture
);
todo_wine_if
(
!
i
)
ok
(
hr
==
(
i
?
S_OK
:
E_INVALIDARG
),
"Test %u: Got unexpected hr %#x.
\n
"
,
i
,
hr
);
ok
(
hr
==
(
i
?
S_OK
:
E_INVALIDARG
),
"Test %u: Got unexpected hr %#x.
\n
"
,
i
,
hr
);
if
(
SUCCEEDED
(
hr
))
if
(
SUCCEEDED
(
hr
))
ID3D11Texture1D_Release
(
texture
);
ID3D11Texture1D_Release
(
texture
);
}
}
...
@@ -6032,6 +6035,532 @@ done:
...
@@ -6032,6 +6035,532 @@ done:
release_test_context
(
&
test_context
);
release_test_context
(
&
test_context
);
}
}
static
void
test_texture1d
(
void
)
{
struct
shader
{
const
DWORD
*
code
;
size_t
size
;
};
struct
texture
{
UINT
width
;
UINT
miplevel_count
;
UINT
array_size
;
DXGI_FORMAT
format
;
D3D11_SUBRESOURCE_DATA
data
[
3
];
};
D3D11_SHADER_RESOURCE_VIEW_DESC
srv_desc
;
struct
d3d11_test_context
test_context
;
const
struct
texture
*
current_texture
;
D3D11_TEXTURE1D_DESC
texture_desc
;
D3D11_SAMPLER_DESC
sampler_desc
;
const
struct
shader
*
current_ps
;
D3D_FEATURE_LEVEL
feature_level
;
ID3D11ShaderResourceView
*
srv
;
ID3D11DeviceContext
*
context
;
ID3D11SamplerState
*
sampler
;
struct
resource_readback
rb
;
ID3D11Texture1D
*
texture
;
struct
vec4
ps_constant
;
ID3D11PixelShader
*
ps
;
ID3D11Device
*
device
;
unsigned
int
i
,
x
;
ID3D11Buffer
*
cb
;
DWORD
color
;
HRESULT
hr
;
static
const
DWORD
ps_ld_code
[]
=
{
#if 0
Texture1D t;
float miplevel;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float2 p;
t.GetDimensions(miplevel, p.x, p.y);
p.y = miplevel;
p *= float2(position.x / 640.0f, 1.0f);
return t.Load(int2(p));
}
#endif
0x43425844
,
0x7b0c6359
,
0x598178f6
,
0xef2ddbdb
,
0x88fc794c
,
0x00000001
,
0x000001ac
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000110
,
0x00000040
,
0x00000044
,
0x04000059
,
0x00208e46
,
0x00000000
,
0x00000001
,
0x04001058
,
0x00107000
,
0x00000000
,
0x00005555
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000001
,
0x0600001c
,
0x00100012
,
0x00000000
,
0x0020800a
,
0x00000000
,
0x00000000
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x0010100a
,
0x00000000
,
0x06000036
,
0x001000e2
,
0x00000000
,
0x00208006
,
0x00000000
,
0x00000000
,
0x0a000038
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3acccccd
,
0x3f800000
,
0x3f800000
,
0x3f800000
,
0x0500001b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0700002d
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x0100003e
,
};
static
const
struct
shader
ps_ld
=
{
ps_ld_code
,
sizeof
(
ps_ld_code
)};
static
const
DWORD
ps_ld_sint8_code
[]
=
{
#if 0
Texture1D<int4> t;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float2 p, s;
int4 c;
p = float2(position.x / 640.0f, 0.0f);
t.GetDimensions(0, s.x, s.y);
p *= s;
c = t.Load(int2(p));
return (max(c / (float4)127, (float4)-1) + (float4)1) / 2.0f;
}
#endif
0x43425844
,
0x65a13d1e
,
0x8a0bfc92
,
0xa2f2708a
,
0x0bafafb6
,
0x00000001
,
0x00000234
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000198
,
0x00000040
,
0x00000066
,
0x04001058
,
0x00107000
,
0x00000000
,
0x00003333
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000002
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x00004001
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000001
,
0x0010100a
,
0x00000000
,
0x00004001
,
0x3acccccd
,
0x08000036
,
0x001000e2
,
0x00000001
,
0x00004002
,
0x00000000
,
0x00000000
,
0x00000000
,
0x00000000
,
0x07000038
,
0x001000f2
,
0x00000000
,
0x00100fc6
,
0x00000000
,
0x00100e46
,
0x00000001
,
0x0500001b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0700002d
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x0500002b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0a000038
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3c010204
,
0x3c010204
,
0x3c010204
,
0x3c010204
,
0x0a000034
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0xbf800000
,
0xbf800000
,
0xbf800000
,
0xbf800000
,
0x0a000000
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3f800000
,
0x3f800000
,
0x3f800000
,
0x3f800000
,
0x0a000038
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3f000000
,
0x3f000000
,
0x3f000000
,
0x3f000000
,
0x0100003e
,
};
static
const
struct
shader
ps_ld_sint8
=
{
ps_ld_sint8_code
,
sizeof
(
ps_ld_sint8_code
)};
static
const
DWORD
ps_ld_uint8_code
[]
=
{
#if 0
Texture1D<uint4> t;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float2 p, s;
p = float2(position.x / 640.0f, 0.0f);
t.GetDimensions(0, s.x, s.y);
p *= s;
return t.Load(int2(p)) / (float4)255;
}
#endif
0x43425844
,
0x35186c1f
,
0x55bad4fd
,
0xb7c97a57
,
0x99c060e7
,
0x00000001
,
0x000001bc
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000120
,
0x00000040
,
0x00000048
,
0x04001058
,
0x00107000
,
0x00000000
,
0x00004444
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000002
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x00004001
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000001
,
0x0010100a
,
0x00000000
,
0x00004001
,
0x3acccccd
,
0x08000036
,
0x001000e2
,
0x00000001
,
0x00004002
,
0x00000000
,
0x00000000
,
0x00000000
,
0x00000000
,
0x07000038
,
0x001000f2
,
0x00000000
,
0x00100fc6
,
0x00000000
,
0x00100e46
,
0x00000001
,
0x0500001b
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0700002d
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x05000056
,
0x001000f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x0a000038
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00004002
,
0x3b808081
,
0x3b808081
,
0x3b808081
,
0x3b808081
,
0x0100003e
,
};
static
const
struct
shader
ps_ld_uint8
=
{
ps_ld_uint8_code
,
sizeof
(
ps_ld_uint8_code
)};
static
DWORD
ps_ld_array_code
[]
=
{
#if 0
Texture1DArray t;
float miplevel;
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
float3 p;
t.GetDimensions(miplevel, p.x, p.y, p.z);
p.y = 1;
p.z = miplevel;
p *= float3(position.x / 640.0f, 1.0f, 1.0f);
return t.Load(int3(p));
}
#endif
0x43425844
,
0xbfccadc4
,
0xc00ff13d
,
0x2ba75365
,
0xf747cbee
,
0x00000001
,
0x000001c0
,
0x00000003
,
0x0000002c
,
0x00000060
,
0x00000094
,
0x4e475349
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000001
,
0x00000003
,
0x00000000
,
0x0000010f
,
0x505f5653
,
0x5449534f
,
0x004e4f49
,
0x4e47534f
,
0x0000002c
,
0x00000001
,
0x00000008
,
0x00000020
,
0x00000000
,
0x00000000
,
0x00000003
,
0x00000000
,
0x0000000f
,
0x545f5653
,
0x45475241
,
0xabab0054
,
0x52444853
,
0x00000124
,
0x00000040
,
0x00000049
,
0x04000059
,
0x00208e46
,
0x00000000
,
0x00000001
,
0x04003858
,
0x00107000
,
0x00000000
,
0x00005555
,
0x04002064
,
0x00101012
,
0x00000000
,
0x00000001
,
0x03000065
,
0x001020f2
,
0x00000000
,
0x02000068
,
0x00000001
,
0x0600001c
,
0x00100012
,
0x00000000
,
0x0020800a
,
0x00000000
,
0x00000000
,
0x0700003d
,
0x001000f2
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x07000038
,
0x00100012
,
0x00000000
,
0x0010000a
,
0x00000000
,
0x0010100a
,
0x00000000
,
0x06000036
,
0x001000c2
,
0x00000000
,
0x00208006
,
0x00000000
,
0x00000000
,
0x0a000038
,
0x00100072
,
0x00000000
,
0x00100386
,
0x00000000
,
0x00004002
,
0x3acccccd
,
0x3f800000
,
0x3f800000
,
0x00000000
,
0x0500001b
,
0x001000d2
,
0x00000000
,
0x00100906
,
0x00000000
,
0x05000036
,
0x00100022
,
0x00000000
,
0x00004001
,
0x00000001
,
0x0700002d
,
0x001020f2
,
0x00000000
,
0x00100e46
,
0x00000000
,
0x00107e46
,
0x00000000
,
0x0100003e
,
};
static
const
struct
shader
ps_ld_array
=
{
ps_ld_array_code
,
sizeof
(
ps_ld_array_code
)};
static
const
DWORD
rgba_level_0
[]
=
{
0xff0000ff
,
0xff00ffff
,
0xff00ff00
,
0xffffff00
,
};
static
const
DWORD
rgba_level_1
[]
=
{
0xffffffff
,
0xff0000ff
,
};
static
const
DWORD
rgba_level_2
[]
=
{
0xffff0000
,
};
static
const
DWORD
srgb_data
[]
=
{
0x00000000
,
0xffffffff
,
0xff000000
,
0x7f7f7f7f
,
};
static
const
DWORD
r32_uint
[]
=
{
0
,
1
,
2
,
3
,
};
static
const
DWORD
r9g9b9e5_data
[]
=
{
0x80000100
,
0x80020000
,
0x84000000
,
0x84000100
,
};
static
const
DWORD
array_data0
[]
=
{
0xff0000ff
,
0xff00ffff
,
0xff00ff00
,
0xffffff00
,
};
static
const
DWORD
array_data1
[]
=
{
0x00ffff00
,
0xff000000
,
0x00ff0000
,
0x000000ff
,
};
static
const
DWORD
array_data2
[]
=
{
0x000000ff
,
0xffff00ff
,
0x0000ff00
,
0xff000000
,
};
static
const
struct
texture
rgba_texture
=
{
4
,
3
,
1
,
DXGI_FORMAT_R8G8B8A8_UNORM
,
{
{
rgba_level_0
,
4
*
sizeof
(
*
rgba_level_0
),
0
},
{
rgba_level_1
,
2
*
sizeof
(
*
rgba_level_1
),
0
},
{
rgba_level_2
,
sizeof
(
*
rgba_level_2
),
0
},
}
};
static
const
struct
texture
srgb_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
{{
srgb_data
,
4
*
sizeof
(
*
srgb_data
)}}};
static
const
struct
texture
sint8_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R8G8B8A8_SINT
,
{{
rgba_level_0
,
4
*
sizeof
(
*
rgba_level_0
)}}};
static
const
struct
texture
uint8_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R8G8B8A8_UINT
,
{{
rgba_level_0
,
4
*
sizeof
(
*
rgba_level_0
)}}};
static
const
struct
texture
r32u_typeless
=
{
4
,
1
,
1
,
DXGI_FORMAT_R32_TYPELESS
,
{{
r32_uint
,
4
*
sizeof
(
*
r32_uint
)}}};
static
const
struct
texture
r9g9b9e5_texture
=
{
4
,
1
,
1
,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP
,
{{
r9g9b9e5_data
,
4
*
sizeof
(
*
r9g9b9e5_data
)}}};
static
const
struct
texture
array_texture
=
{
4
,
1
,
3
,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
{
{
array_data0
,
4
*
sizeof
(
*
array_data0
)},
{
array_data1
,
4
*
sizeof
(
*
array_data1
)},
{
array_data2
,
4
*
sizeof
(
*
array_data2
)},
}
};
static
const
DWORD
level_1_colors
[]
=
{
0xffffffff
,
0xffffffff
,
0xff0000ff
,
0xff0000ff
,
};
static
const
DWORD
level_2_colors
[]
=
{
0xffff0000
,
0xffff0000
,
0xffff0000
,
0xffff0000
,
};
static
const
DWORD
srgb_colors
[]
=
{
0x00000001
,
0xffffffff
,
0xff000000
,
0x7f363636
,
};
static
const
DWORD
sint8_colors
[]
=
{
0x7e80807e
,
0x7e807e7e
,
0x7e807e80
,
0x7e7e7e80
,
};
static
const
DWORD
r32u_colors
[
4
]
=
{
0x01000000
,
0x01000001
,
0x01000002
,
0x01000003
,
};
static
const
DWORD
r9g9b9e5_colors
[
4
]
=
{
0xff0000ff
,
0xff00ff00
,
0xffff0000
,
0xffff00ff
,
};
static
const
DWORD
zero_colors
[
4
]
=
{
0
};
static
const
float
red
[]
=
{
1
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
5
f
};
static
const
struct
texture_test
{
const
struct
shader
*
ps
;
const
struct
texture
*
texture
;
D3D11_FILTER
filter
;
float
lod_bias
;
float
min_lod
;
float
max_lod
;
float
ps_constant
;
const
DWORD
*
expected_colors
;
}
texture_tests
[]
=
{
#define POINT D3D11_FILTER_MIN_MAG_MIP_POINT
#define POINT_LINEAR D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
#define MIP_MAX D3D11_FLOAT32_MAX
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
rgba_level_0
},
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
level_1_colors
},
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
2
.
0
f
,
level_2_colors
},
{
&
ps_ld
,
&
rgba_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
3
.
0
f
,
zero_colors
},
{
&
ps_ld
,
&
srgb_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
srgb_colors
},
{
&
ps_ld
,
&
r9g9b9e5_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
r9g9b9e5_colors
},
{
&
ps_ld
,
NULL
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
zero_colors
},
{
&
ps_ld
,
NULL
,
POINT
,
0
.
0
f
,
0
.
0
f
,
MIP_MAX
,
0
.
0
f
,
zero_colors
},
{
&
ps_ld_sint8
,
&
sint8_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
sint8_colors
},
{
&
ps_ld_uint8
,
&
uint8_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
rgba_level_0
},
{
&
ps_ld_array
,
&
array_texture
,
POINT
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
array_data1
},
};
#undef POINT
#undef POINT_LINEAR
#undef MIP_MAX
static
const
struct
srv_test
{
const
struct
shader
*
ps
;
const
struct
texture
*
texture
;
struct
srv_desc
srv_desc
;
float
ps_constant
;
const
DWORD
*
expected_colors
;
}
srv_tests
[]
=
{
#define TEX_1D D3D11_SRV_DIMENSION_TEXTURE1D
#define R32_UINT DXGI_FORMAT_R32_UINT
{
&
ps_ld_uint8
,
&
r32u_typeless
,
{
R32_UINT
,
TEX_1D
,
0
,
1
},
0
.
0
f
,
r32u_colors
},
#undef TEX_1D
#undef R32_UINT
#undef FMT_UNKNOWN
};
if
(
!
init_test_context
(
&
test_context
,
NULL
))
return
;
device
=
test_context
.
device
;
context
=
test_context
.
immediate_context
;
feature_level
=
ID3D11Device_GetFeatureLevel
(
device
);
cb
=
create_buffer
(
device
,
D3D11_BIND_CONSTANT_BUFFER
,
sizeof
(
ps_constant
),
NULL
);
ID3D11DeviceContext_PSSetConstantBuffers
(
context
,
0
,
1
,
&
cb
);
texture_desc
.
Usage
=
D3D11_USAGE_DEFAULT
;
texture_desc
.
BindFlags
=
D3D11_BIND_SHADER_RESOURCE
;
texture_desc
.
CPUAccessFlags
=
0
;
texture_desc
.
MiscFlags
=
0
;
sampler_desc
.
Filter
=
D3D11_FILTER_MIN_MAG_MIP_POINT
;
sampler_desc
.
AddressU
=
D3D11_TEXTURE_ADDRESS_CLAMP
;
sampler_desc
.
AddressV
=
D3D11_TEXTURE_ADDRESS_CLAMP
;
sampler_desc
.
AddressW
=
D3D11_TEXTURE_ADDRESS_CLAMP
;
sampler_desc
.
MipLODBias
=
0
.
0
f
;
sampler_desc
.
MaxAnisotropy
=
0
;
sampler_desc
.
ComparisonFunc
=
D3D11_COMPARISON_NEVER
;
sampler_desc
.
BorderColor
[
0
]
=
0
.
0
f
;
sampler_desc
.
BorderColor
[
1
]
=
0
.
0
f
;
sampler_desc
.
BorderColor
[
2
]
=
0
.
0
f
;
sampler_desc
.
BorderColor
[
3
]
=
0
.
0
f
;
sampler_desc
.
MinLOD
=
0
.
0
f
;
sampler_desc
.
MaxLOD
=
D3D11_FLOAT32_MAX
;
ps
=
NULL
;
srv
=
NULL
;
sampler
=
NULL
;
texture
=
NULL
;
current_ps
=
NULL
;
current_texture
=
NULL
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
texture_tests
);
++
i
)
{
const
struct
texture_test
*
test
=
&
texture_tests
[
i
];
if
(
current_ps
!=
test
->
ps
)
{
if
(
ps
)
ID3D11PixelShader_Release
(
ps
);
current_ps
=
test
->
ps
;
hr
=
ID3D11Device_CreatePixelShader
(
device
,
current_ps
->
code
,
current_ps
->
size
,
NULL
,
&
ps
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create pixel shader, hr %#x.
\n
"
,
i
,
hr
);
ID3D11DeviceContext_PSSetShader
(
context
,
ps
,
NULL
,
0
);
}
if
(
current_texture
!=
test
->
texture
)
{
if
(
texture
)
ID3D11Texture1D_Release
(
texture
);
if
(
srv
)
ID3D11ShaderResourceView_Release
(
srv
);
current_texture
=
test
->
texture
;
if
(
current_texture
)
{
texture_desc
.
Width
=
current_texture
->
width
;
texture_desc
.
MipLevels
=
current_texture
->
miplevel_count
;
texture_desc
.
ArraySize
=
current_texture
->
array_size
;
texture_desc
.
Format
=
current_texture
->
format
;
hr
=
ID3D11Device_CreateTexture1D
(
device
,
&
texture_desc
,
current_texture
->
data
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create 1d texture, hr %#x.
\n
"
,
i
,
hr
);
hr
=
ID3D11Device_CreateShaderResourceView
(
device
,
(
ID3D11Resource
*
)
texture
,
NULL
,
&
srv
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create shader resource view, hr %#x.
\n
"
,
i
,
hr
);
}
else
{
texture
=
NULL
;
srv
=
NULL
;
}
ID3D11DeviceContext_PSSetShaderResources
(
context
,
0
,
1
,
&
srv
);
}
if
(
!
sampler
||
(
sampler_desc
.
Filter
!=
test
->
filter
||
sampler_desc
.
MipLODBias
!=
test
->
lod_bias
||
sampler_desc
.
MinLOD
!=
test
->
min_lod
||
sampler_desc
.
MaxLOD
!=
test
->
max_lod
))
{
if
(
sampler
)
ID3D11SamplerState_Release
(
sampler
);
sampler_desc
.
Filter
=
test
->
filter
;
sampler_desc
.
MipLODBias
=
test
->
lod_bias
;
sampler_desc
.
MinLOD
=
test
->
min_lod
;
sampler_desc
.
MaxLOD
=
test
->
max_lod
;
hr
=
ID3D11Device_CreateSamplerState
(
device
,
&
sampler_desc
,
&
sampler
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create sampler state, hr %#x.
\n
"
,
i
,
hr
);
ID3D11DeviceContext_PSSetSamplers
(
context
,
0
,
1
,
&
sampler
);
}
ps_constant
.
x
=
test
->
ps_constant
;
ID3D11DeviceContext_UpdateSubresource
(
context
,
(
ID3D11Resource
*
)
cb
,
0
,
NULL
,
&
ps_constant
,
0
,
0
);
ID3D11DeviceContext_ClearRenderTargetView
(
context
,
test_context
.
backbuffer_rtv
,
red
);
draw_quad
(
&
test_context
);
get_texture_readback
(
test_context
.
backbuffer
,
0
,
&
rb
);
for
(
x
=
0
;
x
<
4
;
++
x
)
{
color
=
get_readback_color
(
&
rb
,
80
+
x
*
160
,
0
);
ok
(
compare_color
(
color
,
test
->
expected_colors
[
x
],
2
),
"Test %u: Got unexpected color 0x%08x at (%u).
\n
"
,
i
,
color
,
x
);
}
release_resource_readback
(
&
rb
);
}
if
(
srv
)
ID3D11ShaderResourceView_Release
(
srv
);
ID3D11SamplerState_Release
(
sampler
);
if
(
texture
)
ID3D11Texture1D_Release
(
texture
);
ID3D11PixelShader_Release
(
ps
);
if
(
is_warp_device
(
device
)
&&
feature_level
<
D3D_FEATURE_LEVEL_11_0
)
{
win_skip
(
"SRV tests are broken on WARP.
\n
"
);
ID3D11Buffer_Release
(
cb
);
release_test_context
(
&
test_context
);
return
;
}
sampler_desc
.
Filter
=
D3D11_FILTER_MIN_MAG_MIP_POINT
;
sampler_desc
.
MipLODBias
=
0
.
0
f
;
sampler_desc
.
MinLOD
=
0
.
0
f
;
sampler_desc
.
MaxLOD
=
D3D11_FLOAT32_MAX
;
hr
=
ID3D11Device_CreateSamplerState
(
device
,
&
sampler_desc
,
&
sampler
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create sampler state, hr %#x.
\n
"
,
hr
);
ID3D11DeviceContext_PSSetSamplers
(
context
,
0
,
1
,
&
sampler
);
ps
=
NULL
;
srv
=
NULL
;
texture
=
NULL
;
current_ps
=
NULL
;
current_texture
=
NULL
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
srv_tests
);
++
i
)
{
const
struct
srv_test
*
test
=
&
srv_tests
[
i
];
if
(
current_ps
!=
test
->
ps
)
{
if
(
ps
)
ID3D11PixelShader_Release
(
ps
);
current_ps
=
test
->
ps
;
hr
=
ID3D11Device_CreatePixelShader
(
device
,
current_ps
->
code
,
current_ps
->
size
,
NULL
,
&
ps
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create pixel shader, hr %#x.
\n
"
,
i
,
hr
);
ID3D11DeviceContext_PSSetShader
(
context
,
ps
,
NULL
,
0
);
}
if
(
current_texture
!=
test
->
texture
)
{
if
(
texture
)
ID3D11Texture1D_Release
(
texture
);
current_texture
=
test
->
texture
;
texture_desc
.
Width
=
current_texture
->
width
;
texture_desc
.
MipLevels
=
current_texture
->
miplevel_count
;
texture_desc
.
ArraySize
=
current_texture
->
array_size
;
texture_desc
.
Format
=
current_texture
->
format
;
hr
=
ID3D11Device_CreateTexture1D
(
device
,
&
texture_desc
,
current_texture
->
data
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create 1d texture, hr %#x.
\n
"
,
i
,
hr
);
}
if
(
srv
)
ID3D11ShaderResourceView_Release
(
srv
);
get_srv_desc
(
&
srv_desc
,
&
test
->
srv_desc
);
hr
=
ID3D11Device_CreateShaderResourceView
(
device
,
(
ID3D11Resource
*
)
texture
,
&
srv_desc
,
&
srv
);
ok
(
SUCCEEDED
(
hr
),
"Test %u: Failed to create shader resource view, hr %#x.
\n
"
,
i
,
hr
);
ID3D11DeviceContext_PSSetShaderResources
(
context
,
0
,
1
,
&
srv
);
ps_constant
.
x
=
test
->
ps_constant
;
ID3D11DeviceContext_UpdateSubresource
(
context
,
(
ID3D11Resource
*
)
cb
,
0
,
NULL
,
&
ps_constant
,
0
,
0
);
ID3D11DeviceContext_ClearRenderTargetView
(
context
,
test_context
.
backbuffer_rtv
,
red
);
draw_quad
(
&
test_context
);
get_texture_readback
(
test_context
.
backbuffer
,
0
,
&
rb
);
for
(
x
=
0
;
x
<
4
;
++
x
)
{
color
=
get_readback_color
(
&
rb
,
80
+
x
*
160
,
0
);
ok
(
compare_color
(
color
,
test
->
expected_colors
[
x
],
1
),
"Test %u: Got unexpected color 0x%08x at (%u).
\n
"
,
i
,
color
,
x
);
}
release_resource_readback
(
&
rb
);
}
ID3D11PixelShader_Release
(
ps
);
ID3D11Texture1D_Release
(
texture
);
ID3D11ShaderResourceView_Release
(
srv
);
ID3D11SamplerState_Release
(
sampler
);
ID3D11Buffer_Release
(
cb
);
release_test_context
(
&
test_context
);
}
static
void
test_texture
(
void
)
static
void
test_texture
(
void
)
{
{
struct
shader
struct
shader
...
@@ -25229,6 +25758,7 @@ START_TEST(d3d11)
...
@@ -25229,6 +25758,7 @@ START_TEST(d3d11)
run_for_each_feature_level
(
test_state_refcounting
);
run_for_each_feature_level
(
test_state_refcounting
);
test_device_context_state
();
test_device_context_state
();
test_blend
();
test_blend
();
test_texture1d
();
test_texture
();
test_texture
();
test_cube_maps
();
test_cube_maps
();
test_depth_stencil_sampling
();
test_depth_stencil_sampling
();
dlls/d3d11/texture.c
View file @
fce60001
...
@@ -70,6 +70,14 @@ static ULONG STDMETHODCALLTYPE d3d11_texture1d_AddRef(ID3D11Texture1D *iface)
...
@@ -70,6 +70,14 @@ static ULONG STDMETHODCALLTYPE d3d11_texture1d_AddRef(ID3D11Texture1D *iface)
TRACE
(
"%p increasing refcount to %u.
\n
"
,
texture
,
refcount
);
TRACE
(
"%p increasing refcount to %u.
\n
"
,
texture
,
refcount
);
if
(
refcount
==
1
)
{
ID3D11Device_AddRef
(
texture
->
device
);
wined3d_mutex_lock
();
wined3d_texture_incref
(
texture
->
wined3d_texture
);
wined3d_mutex_unlock
();
}
return
refcount
;
return
refcount
;
}
}
...
@@ -82,9 +90,14 @@ static ULONG STDMETHODCALLTYPE d3d11_texture1d_Release(ID3D11Texture1D *iface)
...
@@ -82,9 +90,14 @@ static ULONG STDMETHODCALLTYPE d3d11_texture1d_Release(ID3D11Texture1D *iface)
if
(
!
refcount
)
if
(
!
refcount
)
{
{
wined3d_private_store_cleanup
(
&
texture
->
private_store
);
ID3D11Device
*
device
=
texture
->
device
;
ID3D11Device_Release
(
texture
->
device
);
heap_free
(
texture
);
wined3d_mutex_lock
();
wined3d_texture_decref
(
texture
->
wined3d_texture
);
wined3d_mutex_unlock
();
/* Release the device last, it may cause the wined3d device to be
* destroyed. */
ID3D11Device_Release
(
device
);
}
}
return
refcount
;
return
refcount
;
...
@@ -178,6 +191,14 @@ static const struct ID3D11Texture1DVtbl d3d11_texture1d_vtbl =
...
@@ -178,6 +191,14 @@ static const struct ID3D11Texture1DVtbl d3d11_texture1d_vtbl =
d3d11_texture1d_GetDesc
,
d3d11_texture1d_GetDesc
,
};
};
struct
d3d_texture1d
*
unsafe_impl_from_ID3D11Texture1D
(
ID3D11Texture1D
*
iface
)
{
if
(
!
iface
)
return
NULL
;
assert
(
iface
->
lpVtbl
==
&
d3d11_texture1d_vtbl
);
return
CONTAINING_RECORD
(
iface
,
struct
d3d_texture1d
,
ID3D11Texture1D_iface
);
}
static
inline
struct
d3d_texture1d
*
impl_from_ID3D10Texture1D
(
ID3D10Texture1D
*
iface
)
static
inline
struct
d3d_texture1d
*
impl_from_ID3D10Texture1D
(
ID3D10Texture1D
*
iface
)
{
{
return
CONTAINING_RECORD
(
iface
,
struct
d3d_texture1d
,
ID3D10Texture1D_iface
);
return
CONTAINING_RECORD
(
iface
,
struct
d3d_texture1d
,
ID3D10Texture1D_iface
);
...
@@ -203,6 +224,14 @@ static ULONG STDMETHODCALLTYPE d3d10_texture1d_AddRef(ID3D10Texture1D *iface)
...
@@ -203,6 +224,14 @@ static ULONG STDMETHODCALLTYPE d3d10_texture1d_AddRef(ID3D10Texture1D *iface)
return
d3d11_texture1d_AddRef
(
&
texture
->
ID3D11Texture1D_iface
);
return
d3d11_texture1d_AddRef
(
&
texture
->
ID3D11Texture1D_iface
);
}
}
static
void
STDMETHODCALLTYPE
d3d_texture1d_wined3d_object_released
(
void
*
parent
)
{
struct
d3d_texture1d
*
texture
=
parent
;
wined3d_private_store_cleanup
(
&
texture
->
private_store
);
heap_free
(
texture
);
}
static
ULONG
STDMETHODCALLTYPE
d3d10_texture1d_Release
(
ID3D10Texture1D
*
iface
)
static
ULONG
STDMETHODCALLTYPE
d3d10_texture1d_Release
(
ID3D10Texture1D
*
iface
)
{
{
struct
d3d_texture1d
*
texture
=
impl_from_ID3D10Texture1D
(
iface
);
struct
d3d_texture1d
*
texture
=
impl_from_ID3D10Texture1D
(
iface
);
...
@@ -317,10 +346,27 @@ static const struct ID3D10Texture1DVtbl d3d10_texture1d_vtbl =
...
@@ -317,10 +346,27 @@ static const struct ID3D10Texture1DVtbl d3d10_texture1d_vtbl =
d3d10_texture1d_GetDesc
,
d3d10_texture1d_GetDesc
,
};
};
struct
d3d_texture1d
*
unsafe_impl_from_ID3D10Texture1D
(
ID3D10Texture1D
*
iface
)
{
if
(
!
iface
)
return
NULL
;
assert
(
iface
->
lpVtbl
==
&
d3d10_texture1d_vtbl
);
return
CONTAINING_RECORD
(
iface
,
struct
d3d_texture1d
,
ID3D10Texture1D_iface
);
}
static
const
struct
wined3d_parent_ops
d3d_texture1d_wined3d_parent_ops
=
{
d3d_texture1d_wined3d_object_released
,
};
HRESULT
d3d_texture1d_create
(
struct
d3d_device
*
device
,
const
D3D11_TEXTURE1D_DESC
*
desc
,
HRESULT
d3d_texture1d_create
(
struct
d3d_device
*
device
,
const
D3D11_TEXTURE1D_DESC
*
desc
,
const
D3D11_SUBRESOURCE_DATA
*
data
,
struct
d3d_texture1d
**
out
)
const
D3D11_SUBRESOURCE_DATA
*
data
,
struct
d3d_texture1d
**
out
)
{
{
struct
wined3d_resource_desc
wined3d_desc
;
struct
d3d_texture1d
*
texture
;
struct
d3d_texture1d
*
texture
;
unsigned
int
levels
;
DWORD
flags
=
0
;
HRESULT
hr
;
if
(
!
(
texture
=
heap_alloc_zero
(
sizeof
(
*
texture
))))
if
(
!
(
texture
=
heap_alloc_zero
(
sizeof
(
*
texture
))))
return
E_OUTOFMEMORY
;
return
E_OUTOFMEMORY
;
...
@@ -328,10 +374,43 @@ HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DE
...
@@ -328,10 +374,43 @@ HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DE
texture
->
ID3D11Texture1D_iface
.
lpVtbl
=
&
d3d11_texture1d_vtbl
;
texture
->
ID3D11Texture1D_iface
.
lpVtbl
=
&
d3d11_texture1d_vtbl
;
texture
->
ID3D10Texture1D_iface
.
lpVtbl
=
&
d3d10_texture1d_vtbl
;
texture
->
ID3D10Texture1D_iface
.
lpVtbl
=
&
d3d10_texture1d_vtbl
;
texture
->
refcount
=
1
;
texture
->
refcount
=
1
;
wined3d_private_store_init
(
&
texture
->
private_store
);
wined3d_private_store_init
(
&
texture
->
private_store
);
texture
->
desc
=
*
desc
;
texture
->
desc
=
*
desc
;
texture
->
desc
.
MipLevels
=
desc
->
MipLevels
?
desc
->
MipLevels
:
wined3d_log2i
(
desc
->
Width
)
+
1
;
levels
=
desc
->
MipLevels
?
desc
->
MipLevels
:
wined3d_log2i
(
desc
->
Width
)
+
1
;
texture
->
desc
.
MipLevels
=
levels
;
wined3d_desc
.
resource_type
=
WINED3D_RTYPE_TEXTURE_1D
;
wined3d_desc
.
format
=
wined3dformat_from_dxgi_format
(
desc
->
Format
);
wined3d_desc
.
multisample_type
=
WINED3D_MULTISAMPLE_NONE
;
wined3d_desc
.
multisample_quality
=
0
;
wined3d_desc
.
usage
=
wined3d_usage_from_d3d11
(
desc
->
BindFlags
,
desc
->
Usage
);
wined3d_desc
.
access
=
wined3d_access_from_d3d11
(
desc
->
Usage
,
desc
->
Usage
==
D3D11_USAGE_DEFAULT
?
0
:
desc
->
CPUAccessFlags
);
wined3d_desc
.
width
=
desc
->
Width
;
wined3d_desc
.
height
=
1
;
wined3d_desc
.
depth
=
1
;
wined3d_desc
.
size
=
0
;
if
(
desc
->
MiscFlags
&
D3D11_RESOURCE_MISC_GDI_COMPATIBLE
)
flags
|=
WINED3D_TEXTURE_CREATE_GET_DC
;
if
(
desc
->
MiscFlags
&
D3D11_RESOURCE_MISC_GENERATE_MIPS
)
flags
|=
WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS
;
wined3d_mutex_lock
();
hr
=
wined3d_texture_create
(
device
->
wined3d_device
,
&
wined3d_desc
,
desc
->
ArraySize
,
levels
,
flags
,
(
struct
wined3d_sub_resource_data
*
)
data
,
texture
,
&
d3d_texture1d_wined3d_parent_ops
,
&
texture
->
wined3d_texture
);
wined3d_mutex_unlock
();
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to create wined3d texture, hr %#x.
\n
"
,
hr
);
wined3d_private_store_cleanup
(
&
texture
->
private_store
);
heap_free
(
texture
);
if
(
hr
==
WINED3DERR_NOTAVAILABLE
||
hr
==
WINED3DERR_INVALIDCALL
)
hr
=
E_INVALIDARG
;
return
hr
;
}
texture
->
device
=
&
device
->
ID3D11Device_iface
;
texture
->
device
=
&
device
->
ID3D11Device_iface
;
ID3D11Device_AddRef
(
texture
->
device
);
ID3D11Device_AddRef
(
texture
->
device
);
...
...
dlls/d3d11/utils.c
View file @
fce60001
...
@@ -713,6 +713,10 @@ struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *re
...
@@ -713,6 +713,10 @@ struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *re
return
wined3d_buffer_get_resource
(
unsafe_impl_from_ID3D11Buffer
(
return
wined3d_buffer_get_resource
(
unsafe_impl_from_ID3D11Buffer
(
(
ID3D11Buffer
*
)
resource
)
->
wined3d_buffer
);
(
ID3D11Buffer
*
)
resource
)
->
wined3d_buffer
);
case
D3D11_RESOURCE_DIMENSION_TEXTURE1D
:
return
wined3d_texture_get_resource
(
unsafe_impl_from_ID3D11Texture1D
(
(
ID3D11Texture1D
*
)
resource
)
->
wined3d_texture
);
case
D3D11_RESOURCE_DIMENSION_TEXTURE2D
:
case
D3D11_RESOURCE_DIMENSION_TEXTURE2D
:
return
wined3d_texture_get_resource
(
unsafe_impl_from_ID3D11Texture2D
(
return
wined3d_texture_get_resource
(
unsafe_impl_from_ID3D11Texture2D
(
(
ID3D11Texture2D
*
)
resource
)
->
wined3d_texture
);
(
ID3D11Texture2D
*
)
resource
)
->
wined3d_texture
);
...
@@ -739,6 +743,10 @@ struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *re
...
@@ -739,6 +743,10 @@ struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *re
return
wined3d_buffer_get_resource
(
unsafe_impl_from_ID3D10Buffer
(
return
wined3d_buffer_get_resource
(
unsafe_impl_from_ID3D10Buffer
(
(
ID3D10Buffer
*
)
resource
)
->
wined3d_buffer
);
(
ID3D10Buffer
*
)
resource
)
->
wined3d_buffer
);
case
D3D10_RESOURCE_DIMENSION_TEXTURE1D
:
return
wined3d_texture_get_resource
(
unsafe_impl_from_ID3D10Texture1D
(
(
ID3D10Texture1D
*
)
resource
)
->
wined3d_texture
);
case
D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
case
D3D10_RESOURCE_DIMENSION_TEXTURE2D
:
return
wined3d_texture_get_resource
(
unsafe_impl_from_ID3D10Texture2D
(
return
wined3d_texture_get_resource
(
unsafe_impl_from_ID3D10Texture2D
(
(
ID3D10Texture2D
*
)
resource
)
->
wined3d_texture
);
(
ID3D10Texture2D
*
)
resource
)
->
wined3d_texture
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment