ReactOS 0.4.17-dev-966-gf06eace
reflection.c File Reference
#include "initguid.h"
#include "d3dcompiler_private.h"
#include "d3d10.h"
Include dependency graph for reflection.c:

Go to the source code of this file.

Classes

struct  d3dcompiler_shader_signature
 
struct  d3dcompiler_shader_reflection_type
 
struct  d3dcompiler_shader_reflection_type_member
 
struct  d3dcompiler_shader_reflection_variable
 
struct  d3dcompiler_shader_reflection_constant_buffer
 
struct  d3dcompiler_shader_reflection
 

Macros

#define ID3D11ShaderReflection   ID3D10ShaderReflection
 
#define ID3D11ShaderReflectionVtbl   ID3D10ShaderReflectionVtbl
 
#define ID3D11ShaderReflectionConstantBuffer   ID3D10ShaderReflectionConstantBuffer
 
#define ID3D11ShaderReflectionConstantBufferVtbl   ID3D10ShaderReflectionConstantBufferVtbl
 
#define ID3D11ShaderReflectionType   ID3D10ShaderReflectionType
 
#define ID3D11ShaderReflectionTypeVtbl   ID3D10ShaderReflectionTypeVtbl
 
#define ID3D11ShaderReflectionVariable   ID3D10ShaderReflectionVariable
 
#define ID3D11ShaderReflectionVariableVtbl   ID3D10ShaderReflectionVariableVtbl
 
#define IID_ID3D11ShaderReflection   IID_ID3D10ShaderReflection
 
#define D3D11_SHADER_BUFFER_DESC   D3D10_SHADER_BUFFER_DESC
 
#define D3D11_SHADER_DESC   D3D10_SHADER_DESC
 
#define D3D11_SHADER_INPUT_BIND_DESC   D3D10_SHADER_INPUT_BIND_DESC
 
#define D3D11_SHADER_TYPE_DESC   D3D10_SHADER_TYPE_DESC
 
#define D3D11_SHADER_VARIABLE_DESC   D3D10_SHADER_VARIABLE_DESC
 
#define D3D11_SIGNATURE_PARAMETER_DESC   D3D10_SIGNATURE_PARAMETER_DESC
 
#define D3DCOMPILER_SHADER_TARGET_VERSION_MASK   0xffff
 
#define D3DCOMPILER_SHADER_TARGET_SHADERTYPE_MASK   0xffff0000
 
#define D3DCOMPILER_SHADER_TARGET_SHADERTYPE_SHIFT   16
 
#define D3DCOMPILER_SHDR_SHADER_TYPE_CS   0x4353
 
#define SM4_OPCODE_MASK   0xff
 
#define SM4_INSTRUCTION_LENGTH_SHIFT   24
 
#define SM4_INSTRUCTION_LENGTH_MASK   (0x1fu << SM4_INSTRUCTION_LENGTH_SHIFT)
 

Enumerations

enum  D3DCOMPILER_SIGNATURE_ELEMENT_SIZE { D3DCOMPILER_SIGNATURE_ELEMENT_SIZE6 = 6 , D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7 = 7 }
 
enum  d3dcompiler_shader_type { D3DCOMPILER_SHADER_TYPE_CS = 5 }
 
enum  D3DCOMPILER_REFLECTION_VERSION { D3DCOMPILER_REFLECTION_VERSION_D3D10 , D3DCOMPILER_REFLECTION_VERSION_D3D11 , D3DCOMPILER_REFLECTION_VERSION_D3D12 }
 
enum  sm4_opcode { SM5_OP_DCL_THREAD_GROUP = 0x9b }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dcompiler)
 
static struct d3dcompiler_shader_reflection_type * get_reflection_type (struct d3dcompiler_shader_reflection *reflection, const char *data, uint32_t offset)
 
static BOOL copy_name (const char *ptr, char **name)
 
static BOOL copy_value (const char *ptr, void **value, uint32_t size)
 
static int d3dcompiler_shader_reflection_type_compare (const void *key, const struct wine_rb_entry *entry)
 
static void free_type_member (struct d3dcompiler_shader_reflection_type_member *member)
 
static void d3dcompiler_shader_reflection_type_destroy (struct wine_rb_entry *entry, void *context)
 
static void free_signature (struct d3dcompiler_shader_signature *sig)
 
static void free_variable (struct d3dcompiler_shader_reflection_variable *var)
 
static void free_constant_buffer (struct d3dcompiler_shader_reflection_constant_buffer *cb)
 
static void reflection_cleanup (struct d3dcompiler_shader_reflection *ref)
 
static struct d3dcompiler_shader_reflection * impl_from_ID3D11ShaderReflection (ID3D11ShaderReflection *iface)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_QueryInterface (ID3D11ShaderReflection *iface, REFIID riid, void **object)
 
static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_AddRef (ID3D11ShaderReflection *iface)
 
static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release (ID3D11ShaderReflection *iface)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc (ID3D11ShaderReflection *iface, D3D11_SHADER_DESC *desc)
 
static struct ID3D11ShaderReflectionConstantBuffer *STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByIndex (ID3D11ShaderReflection *iface, UINT index)
 
static struct ID3D11ShaderReflectionConstantBuffer *STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByName (ID3D11ShaderReflection *iface, const char *name)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDesc (ID3D11ShaderReflection *iface, UINT index, D3D11_SHADER_INPUT_BIND_DESC *desc)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameterDesc (ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParameterDesc (ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
 
static struct d3dcompiler_shader_reflection_constant_buffer * impl_from_ID3D11ShaderReflectionConstantBuffer (ID3D11ShaderReflectionConstantBuffer *iface)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetDesc (ID3D11ShaderReflectionConstantBuffer *iface, D3D11_SHADER_BUFFER_DESC *desc)
 
static ID3D11ShaderReflectionVariable *STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByIndex (ID3D11ShaderReflectionConstantBuffer *iface, UINT index)
 
static ID3D11ShaderReflectionVariable *STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByName (ID3D11ShaderReflectionConstantBuffer *iface, const char *name)
 
static struct d3dcompiler_shader_reflection_variable * impl_from_ID3D11ShaderReflectionVariable (ID3D11ShaderReflectionVariable *iface)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetDesc (ID3D11ShaderReflectionVariable *iface, D3D11_SHADER_VARIABLE_DESC *desc)
 
static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetType (ID3D11ShaderReflectionVariable *iface)
 
static struct d3dcompiler_shader_reflection_type * impl_from_ID3D11ShaderReflectionType (ID3D11ShaderReflectionType *iface)
 
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetDesc (ID3D11ShaderReflectionType *iface, D3D11_SHADER_TYPE_DESC *desc)
 
static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByIndex (ID3D11ShaderReflectionType *iface, UINT index)
 
static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByName (ID3D11ShaderReflectionType *iface, const char *name)
 
static const char *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeName (ID3D11ShaderReflectionType *iface, UINT index)
 
static HRESULT d3dcompiler_parse_stat (struct d3dcompiler_shader_reflection *r, const char *data, size_t data_size)
 
static HRESULT d3dcompiler_parse_type_members (struct d3dcompiler_shader_reflection *ref, struct d3dcompiler_shader_reflection_type_member *member, const char *data, const char **ptr)
 
static HRESULT d3dcompiler_parse_type (struct d3dcompiler_shader_reflection_type *type, const char *data, uint32_t offset)
 
static HRESULT d3dcompiler_parse_variables (struct d3dcompiler_shader_reflection_constant_buffer *cb, const char *data, size_t data_size, const char *ptr)
 
static HRESULT d3dcompiler_parse_rdef (struct d3dcompiler_shader_reflection *r, const char *data, size_t data_size)
 
static HRESULT d3dcompiler_parse_signature (struct d3dcompiler_shader_signature *s, const struct vkd3d_shader_dxbc_section_desc *section)
 
static HRESULT d3dcompiler_parse_shdr (struct d3dcompiler_shader_reflection *r, const char *data, size_t data_size)
 
static HRESULT d3dcompiler_shader_reflection_init (struct d3dcompiler_shader_reflection *reflection, const void *data, SIZE_T data_size)
 
HRESULT WINAPI D3D10ReflectShader (const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector)
 

Variables

static const struct ID3D11ShaderReflectionConstantBufferVtbl d3dcompiler_shader_reflection_constant_buffer_vtbl
 
static const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflection_variable_vtbl
 
static const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection_type_vtbl
 
static struct d3dcompiler_shader_reflection_constant_buffer null_constant_buffer
 
static struct d3dcompiler_shader_reflection_type null_type
 
static struct d3dcompiler_shader_reflection_variable null_variable
 
static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl
 

Macro Definition Documentation

◆ D3D11_SHADER_BUFFER_DESC

◆ D3D11_SHADER_DESC

Definition at line 36 of file reflection.c.

◆ D3D11_SHADER_INPUT_BIND_DESC

◆ D3D11_SHADER_TYPE_DESC

◆ D3D11_SHADER_VARIABLE_DESC

◆ D3D11_SIGNATURE_PARAMETER_DESC

◆ D3DCOMPILER_SHADER_TARGET_SHADERTYPE_MASK

#define D3DCOMPILER_SHADER_TARGET_SHADERTYPE_MASK   0xffff0000

Definition at line 52 of file reflection.c.

◆ D3DCOMPILER_SHADER_TARGET_SHADERTYPE_SHIFT

#define D3DCOMPILER_SHADER_TARGET_SHADERTYPE_SHIFT   16

Definition at line 53 of file reflection.c.

◆ D3DCOMPILER_SHADER_TARGET_VERSION_MASK

#define D3DCOMPILER_SHADER_TARGET_VERSION_MASK   0xffff

Definition at line 51 of file reflection.c.

◆ D3DCOMPILER_SHDR_SHADER_TYPE_CS

#define D3DCOMPILER_SHDR_SHADER_TYPE_CS   0x4353

Definition at line 55 of file reflection.c.

◆ ID3D11ShaderReflection

#define ID3D11ShaderReflection   ID3D10ShaderReflection

Definition at line 26 of file reflection.c.

◆ ID3D11ShaderReflectionConstantBuffer

#define ID3D11ShaderReflectionConstantBuffer   ID3D10ShaderReflectionConstantBuffer

Definition at line 28 of file reflection.c.

◆ ID3D11ShaderReflectionConstantBufferVtbl

#define ID3D11ShaderReflectionConstantBufferVtbl   ID3D10ShaderReflectionConstantBufferVtbl

Definition at line 29 of file reflection.c.

◆ ID3D11ShaderReflectionType

#define ID3D11ShaderReflectionType   ID3D10ShaderReflectionType

Definition at line 30 of file reflection.c.

◆ ID3D11ShaderReflectionTypeVtbl

#define ID3D11ShaderReflectionTypeVtbl   ID3D10ShaderReflectionTypeVtbl

Definition at line 31 of file reflection.c.

◆ ID3D11ShaderReflectionVariable

#define ID3D11ShaderReflectionVariable   ID3D10ShaderReflectionVariable

Definition at line 32 of file reflection.c.

◆ ID3D11ShaderReflectionVariableVtbl

#define ID3D11ShaderReflectionVariableVtbl   ID3D10ShaderReflectionVariableVtbl

Definition at line 33 of file reflection.c.

◆ ID3D11ShaderReflectionVtbl

#define ID3D11ShaderReflectionVtbl   ID3D10ShaderReflectionVtbl

Definition at line 27 of file reflection.c.

◆ IID_ID3D11ShaderReflection

#define IID_ID3D11ShaderReflection   IID_ID3D10ShaderReflection

Definition at line 34 of file reflection.c.

◆ SM4_INSTRUCTION_LENGTH_MASK

#define SM4_INSTRUCTION_LENGTH_MASK   (0x1fu << SM4_INSTRUCTION_LENGTH_SHIFT)

Definition at line 1773 of file reflection.c.

◆ SM4_INSTRUCTION_LENGTH_SHIFT

#define SM4_INSTRUCTION_LENGTH_SHIFT   24

Definition at line 1772 of file reflection.c.

◆ SM4_OPCODE_MASK

#define SM4_OPCODE_MASK   0xff

Definition at line 1771 of file reflection.c.

Enumeration Type Documentation

◆ D3DCOMPILER_REFLECTION_VERSION

Enumerator
D3DCOMPILER_REFLECTION_VERSION_D3D10 
D3DCOMPILER_REFLECTION_VERSION_D3D11 
D3DCOMPILER_REFLECTION_VERSION_D3D12 

Definition at line 119 of file reflection.c.

120{
124};
@ D3DCOMPILER_REFLECTION_VERSION_D3D10
Definition: reflection.c:121
@ D3DCOMPILER_REFLECTION_VERSION_D3D11
Definition: reflection.c:122
@ D3DCOMPILER_REFLECTION_VERSION_D3D12
Definition: reflection.c:123

◆ d3dcompiler_shader_type

Enumerator
D3DCOMPILER_SHADER_TYPE_CS 

Definition at line 57 of file reflection.c.

58{
60};
@ D3DCOMPILER_SHADER_TYPE_CS
Definition: reflection.c:59

◆ D3DCOMPILER_SIGNATURE_ELEMENT_SIZE

Enumerator
D3DCOMPILER_SIGNATURE_ELEMENT_SIZE6 
D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7 

Definition at line 45 of file reflection.c.

46{
49};
@ D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7
Definition: reflection.c:48
@ D3DCOMPILER_SIGNATURE_ELEMENT_SIZE6
Definition: reflection.c:47

◆ sm4_opcode

Enumerator
SM5_OP_DCL_THREAD_GROUP 

Definition at line 1775 of file reflection.c.

1776{
1778};
@ SM5_OP_DCL_THREAD_GROUP
Definition: reflection.c:1777

Function Documentation

◆ copy_name()

static BOOL copy_name ( const char *  ptr,
char **  name 
)
static

Definition at line 204 of file reflection.c.

205{
206 if (!ptr || !ptr[0]) return TRUE;
207
208 *name = strdup(ptr);
209 if (!*name)
210 {
211 ERR("Failed to allocate name memory.\n");
212 return FALSE;
213 }
214
215 return TRUE;
216}
#define ERR(fmt,...)
Definition: precomp.h:57
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static char * strdup(const char *buf)
Definition: string.h:83
static PVOID ptr
Definition: dispmode.c:27
Definition: name.c:39

Referenced by d3dcompiler_parse_rdef(), d3dcompiler_parse_type(), d3dcompiler_parse_type_members(), and d3dcompiler_parse_variables().

◆ copy_value()

static BOOL copy_value ( const char *  ptr,
void **  value,
uint32_t  size 
)
static

Definition at line 218 of file reflection.c.

219{
220 if (!ptr || !size) return TRUE;
221
222 *value = malloc(size);
223 if (!*value)
224 {
225 ERR("Failed to allocate value memory.\n");
226 return FALSE;
227 }
228
229 memcpy(*value, ptr, size);
230
231 return TRUE;
232}
#define malloc
Definition: debug_ros.c:4
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: pdh_main.c:64

Referenced by d3dcompiler_parse_variables().

◆ D3D10ReflectShader()

HRESULT WINAPI D3D10ReflectShader ( const void *  data,
SIZE_T  data_size,
ID3D10ShaderReflection **  reflector 
)

Definition at line 1969 of file reflection.c.

1970{
1972 HRESULT hr;
1973
1974 TRACE("data %p, data_size %Iu, reflector %p.\n", data, data_size, reflector);
1975
1976 if (!(object = calloc(1, sizeof(*object))))
1977 {
1978 ERR("Failed to allocate D3D10 shader reflection object memory.\n");
1979 return E_OUTOFMEMORY;
1980 }
1981
1982 object->ID3D11ShaderReflection_iface.lpVtbl = &d3dcompiler_shader_reflection_vtbl;
1983 object->interface_version = D3DCOMPILER_REFLECTION_VERSION_D3D10;
1984 object->refcount = 1;
1985
1986 hr = d3dcompiler_shader_reflection_init(object, data, data_size);
1987 if (FAILED(hr))
1988 {
1989 WARN("Failed to initialize shader reflection.\n");
1990 free(object);
1991 return hr;
1992 }
1993
1994 *reflector = (ID3D10ShaderReflection *)&object->ID3D11ShaderReflection_iface;
1995
1996 TRACE("Created ID3D10ShaderReflection %p.\n", object);
1997
1998 return S_OK;
1999}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl
Definition: reflection.c:737
static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_reflection *reflection, const void *data, SIZE_T data_size)
Definition: reflection.c:1847
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by call_reflect(), parse_fx10_shader(), and test_d3d10_interfaces().

◆ d3dcompiler_parse_rdef()

static HRESULT d3dcompiler_parse_rdef ( struct d3dcompiler_shader_reflection *  r,
const char *  data,
size_t  data_size 
)
static

Definition at line 1472 of file reflection.c.

1473{
1474 struct d3dcompiler_shader_reflection_constant_buffer *constant_buffers = NULL;
1475 uint32_t offset, cbuffer_offset, resource_offset, creator_offset;
1476 unsigned int i, string_data_offset, string_data_size;
1477 D3D12_SHADER_INPUT_BIND_DESC *bound_resources = NULL;
1478 char *string_data = NULL, *creator = NULL;
1479 size_t size = data_size >> 2;
1480 uint32_t target_version;
1481 const char *ptr = data;
1482#if D3D_COMPILER_VERSION < 47
1484#endif
1485 HRESULT hr;
1486
1487 TRACE("Size %Iu.\n", size);
1488
1489 r->constant_buffer_count = read_u32(&ptr);
1490 TRACE("Constant buffer count: %u.\n", r->constant_buffer_count);
1491
1492 cbuffer_offset = read_u32(&ptr);
1493 TRACE("Constant buffer offset: %#x.\n", cbuffer_offset);
1494
1495 r->bound_resource_count = read_u32(&ptr);
1496 TRACE("Bound resource count: %u.\n", r->bound_resource_count);
1497
1498 resource_offset = read_u32(&ptr);
1499 TRACE("Bound resource offset: %#x.\n", resource_offset);
1500
1501 r->target = read_u32(&ptr);
1502 TRACE("Target: %#x.\n", r->target);
1503
1504 target_version = r->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK;
1505#if D3D_COMPILER_VERSION < 47
1508 if ((target_version >= 0x501 && shader_type != D3DCOMPILER_SHDR_SHADER_TYPE_CS)
1510 {
1511 WARN("Target version %#x is not supported in d3dcompiler %u.\n", target_version, D3D_COMPILER_VERSION);
1512 return E_INVALIDARG;
1513 }
1514#endif
1515
1516 r->flags = read_u32(&ptr);
1517 TRACE("Flags: %u.\n", r->flags);
1518
1519 creator_offset = read_u32(&ptr);
1520 TRACE("Creator at offset %#x.\n", creator_offset);
1521
1522 if (!copy_name(data + creator_offset, &creator))
1523 {
1524 ERR("Failed to copy name.\n");
1525 return E_OUTOFMEMORY;
1526 }
1527 TRACE("Creator: %s.\n", debugstr_a(creator));
1528
1529 /* todo: Parse RD11 */
1530 if (target_version >= 0x500)
1531 {
1532 skip_u32_unknown(&ptr, 8);
1533 }
1534
1535 if (r->bound_resource_count)
1536 {
1537 /* 8 for each bind desc */
1538 string_data_offset = resource_offset + r->bound_resource_count * 8 * sizeof(uint32_t);
1539 string_data_size = (cbuffer_offset ? cbuffer_offset : creator_offset) - string_data_offset;
1540
1541 string_data = malloc(string_data_size);
1542 if (!string_data)
1543 {
1544 ERR("Failed to allocate string data memory.\n");
1545 hr = E_OUTOFMEMORY;
1546 goto err_out;
1547 }
1548 memcpy(string_data, data + string_data_offset, string_data_size);
1549
1550 bound_resources = calloc(r->bound_resource_count, sizeof(*bound_resources));
1551 if (!bound_resources)
1552 {
1553 ERR("Failed to allocate resources memory.\n");
1554 hr = E_OUTOFMEMORY;
1555 goto err_out;
1556 }
1557
1558 ptr = data + resource_offset;
1559 for (i = 0; i < r->bound_resource_count; i++)
1560 {
1561 D3D12_SHADER_INPUT_BIND_DESC *desc = &bound_resources[i];
1562
1563 offset = read_u32(&ptr);
1564 desc->Name = string_data + (offset - string_data_offset);
1565 TRACE("Input bind Name: %s.\n", debugstr_a(desc->Name));
1566
1567 desc->Type = read_u32(&ptr);
1568 TRACE("Input bind Type: %#x.\n", desc->Type);
1569
1570 desc->ReturnType = read_u32(&ptr);
1571 TRACE("Input bind ReturnType: %#x.\n", desc->ReturnType);
1572
1573 desc->Dimension = read_u32(&ptr);
1574 TRACE("Input bind Dimension: %#x.\n", desc->Dimension);
1575
1576 desc->NumSamples = read_u32(&ptr);
1577 TRACE("Input bind NumSamples: %u.\n", desc->NumSamples);
1578
1579 desc->BindPoint = read_u32(&ptr);
1580 TRACE("Input bind BindPoint: %u.\n", desc->BindPoint);
1581
1582 desc->BindCount = read_u32(&ptr);
1583 TRACE("Input bind BindCount: %u.\n", desc->BindCount);
1584
1585 desc->uFlags = read_u32(&ptr);
1586 TRACE("Input bind uFlags: %u.\n", desc->uFlags);
1587
1588 if (target_version >= 0x501)
1589 {
1590 desc->Space = read_u32(&ptr);
1591 TRACE("Input bind Space %u.\n", desc->Space);
1592 desc->uID = read_u32(&ptr);
1593 TRACE("Input bind uID %u.\n", desc->uID);
1594 }
1595 else
1596 {
1597 desc->uID = desc->BindPoint;
1598 }
1599 }
1600 }
1601
1602 if (r->constant_buffer_count)
1603 {
1604 constant_buffers = calloc(r->constant_buffer_count, sizeof(*constant_buffers));
1605 if (!constant_buffers)
1606 {
1607 ERR("Failed to allocate constant buffer memory.\n");
1608 hr = E_OUTOFMEMORY;
1609 goto err_out;
1610 }
1611
1612 ptr = data + cbuffer_offset;
1613 for (i = 0; i < r->constant_buffer_count; i++)
1614 {
1615 struct d3dcompiler_shader_reflection_constant_buffer *cb = &constant_buffers[i];
1616
1617 cb->ID3D11ShaderReflectionConstantBuffer_iface.lpVtbl = &d3dcompiler_shader_reflection_constant_buffer_vtbl;
1618 cb->reflection = r;
1619
1620 offset = read_u32(&ptr);
1621 if (!copy_name(data + offset, &cb->name))
1622 {
1623 ERR("Failed to copy name.\n");
1624 hr = E_OUTOFMEMORY;
1625 goto err_out;
1626 }
1627 TRACE("Name: %s.\n", debugstr_a(cb->name));
1628
1629 cb->variable_count = read_u32(&ptr);
1630 TRACE("Variable count: %u.\n", cb->variable_count);
1631
1632 offset = read_u32(&ptr);
1633 TRACE("Variable offset: %x.\n", offset);
1634
1635 hr = d3dcompiler_parse_variables(cb, data, data_size, data + offset);
1636 if (hr != S_OK)
1637 {
1638 FIXME("Failed to parse variables.\n");
1639 goto err_out;
1640 }
1641
1642 cb->size = read_u32(&ptr);
1643 TRACE("Cbuffer size: %u.\n", cb->size);
1644
1645 cb->flags = read_u32(&ptr);
1646 TRACE("Cbuffer flags: %u.\n", cb->flags);
1647
1648 cb->type = read_u32(&ptr);
1649 TRACE("Cbuffer type: %#x.\n", cb->type);
1650 }
1651 }
1652
1653 r->creator = creator;
1654 r->resource_string = string_data;
1655 r->bound_resources = bound_resources;
1656 r->constant_buffers = constant_buffers;
1657
1658 return S_OK;
1659
1660err_out:
1661 for (i = 0; i < r->constant_buffer_count; ++i)
1662 {
1663 free_constant_buffer(&constant_buffers[i]);
1664 }
1665 free(constant_buffers);
1666 free(bound_resources);
1667 free(string_data);
1668 free(creator);
1669
1670 return hr;
1671}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define D3D_COMPILER_VERSION
Definition: d3d11shader.h:26
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
#define D3DCOMPILER_SHADER_TARGET_SHADERTYPE_SHIFT
Definition: reflection.c:53
#define D3DCOMPILER_SHADER_TARGET_SHADERTYPE_MASK
Definition: reflection.c:52
#define D3DCOMPILER_SHADER_TARGET_VERSION_MASK
Definition: reflection.c:51
static const struct ID3D11ShaderReflectionConstantBufferVtbl d3dcompiler_shader_reflection_constant_buffer_vtbl
Definition: reflection.c:184
static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_constant_buffer *cb, const char *data, size_t data_size, const char *ptr)
Definition: reflection.c:1396
static void free_constant_buffer(struct d3dcompiler_shader_reflection_constant_buffer *cb)
Definition: reflection.c:287
static BOOL copy_name(const char *ptr, char **name)
Definition: reflection.c:204
#define D3DCOMPILER_SHDR_SHADER_TYPE_CS
Definition: reflection.c:55
void skip_u32_unknown(const char **ptr, unsigned int count)
Definition: utils.c:516
static uint32_t read_u32(const char **ptr)
Definition: utils.h:24
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_a
Definition: kernel32.h:31
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
#define uint32_t
Definition: nsiface.idl:61

Referenced by d3dcompiler_shader_reflection_init().

◆ d3dcompiler_parse_shdr()

static HRESULT d3dcompiler_parse_shdr ( struct d3dcompiler_shader_reflection *  r,
const char *  data,
size_t  data_size 
)
static

Definition at line 1780 of file reflection.c.

1781{
1782 uint32_t opcode_token, opcode;
1784 const char *ptr = data;
1785 const uint32_t *u_ptr;
1786 unsigned int len;
1787
1788 r->version = read_u32(&ptr);
1789 TRACE("Shader version: %u\n", r->version);
1790
1793
1795 {
1796 /* TODO: Check if anything else is needed from the SHDR or SHEX blob. */
1797 return S_OK;
1798 }
1799
1800 size = read_u32(&ptr);
1801 TRACE("size %u.\n", size);
1802 if (size * sizeof(uint32_t) != data_size || size < 2)
1803 {
1804 WARN("Invalid size %u.\n", size);
1805 return E_FAIL;
1806 }
1807 size -= 2;
1808 u_ptr = (uint32_t *)ptr;
1809 while (size)
1810 {
1811 opcode_token = *u_ptr;
1812 opcode = opcode_token & SM4_OPCODE_MASK;
1814 if (!len)
1815 {
1816 if (size < 2)
1817 {
1818 WARN("End of byte-code, failed to read length token.\n");
1819 return E_FAIL;
1820 }
1821 len = u_ptr[1];
1822 }
1823 if (!len || size < len)
1824 {
1825 WARN("Invalid instruction length %u, size %u.\n", len, size);
1826 return E_FAIL;
1827 }
1828 if (opcode == SM5_OP_DCL_THREAD_GROUP)
1829 {
1830 if (len != 4)
1831 {
1832 WARN("Invalid dcl_thread_group opcode length %u.\n", len);
1833 return E_FAIL;
1834 }
1835 r->thread_group_size_x = u_ptr[1];
1836 r->thread_group_size_y = u_ptr[2];
1837 r->thread_group_size_z = u_ptr[3];
1838 TRACE("Found dcl_thread_group %u, %u, %u.\n",
1839 r->thread_group_size_x, r->thread_group_size_y, r->thread_group_size_z);
1840 }
1841 size -= len;
1842 u_ptr += len;
1843 }
1844 return S_OK;
1845}
#define E_FAIL
Definition: ddrawi.h:102
#define SM4_OPCODE_MASK
Definition: reflection.c:1771
#define SM4_INSTRUCTION_LENGTH_SHIFT
Definition: reflection.c:1772
#define SM4_INSTRUCTION_LENGTH_MASK
Definition: reflection.c:1773
GLenum GLsizei len
Definition: glext.h:6722

Referenced by d3dcompiler_shader_reflection_init().

◆ d3dcompiler_parse_signature()

static HRESULT d3dcompiler_parse_signature ( struct d3dcompiler_shader_signature *  s,
const struct vkd3d_shader_dxbc_section_desc *  section 
)
static

Definition at line 1673 of file reflection.c.

1675{
1677 const char *ptr = section->data.code;
1679 unsigned int string_data_offset;
1680 unsigned int string_data_size;
1681 unsigned int i, count;
1682 char *string_data;
1683
1684 switch (section->tag)
1685 {
1686 case TAG_OSG5:
1688 break;
1689
1690 case TAG_ISGN:
1691 case TAG_OSGN:
1692 case TAG_PCSG:
1694 break;
1695
1696 default:
1697 FIXME("Unhandled section %s!\n", debugstr_fourcc(section->tag));
1699 break;
1700 }
1701
1702 count = read_u32(&ptr);
1703 TRACE("%u elements\n", count);
1704
1705 skip_u32_unknown(&ptr, 1);
1706
1707 d = calloc(count, sizeof(*d));
1708 if (!d)
1709 {
1710 ERR("Failed to allocate signature memory.\n");
1711 return E_OUTOFMEMORY;
1712 }
1713
1714 /* 2 u32s for the header, element_size for each element. */
1715 string_data_offset = 2 * sizeof(uint32_t) + count * element_size * sizeof(uint32_t);
1716 string_data_size = section->data.size - string_data_offset;
1717
1718 string_data = malloc(string_data_size);
1719 if (!string_data)
1720 {
1721 ERR("Failed to allocate string data memory.\n");
1722 free(d);
1723 return E_OUTOFMEMORY;
1724 }
1725 memcpy(string_data, (const char *)section->data.code + string_data_offset, string_data_size);
1726
1727 for (i = 0; i < count; ++i)
1728 {
1729 uint32_t name_offset, mask;
1730
1731#if D3D_COMPILER_VERSION >= 46
1732 /* FIXME */
1733 d[i].MinPrecision = D3D_MIN_PRECISION_DEFAULT;
1734#endif
1735#if D3D_COMPILER_VERSION
1737 {
1738 d[i].Stream = read_u32(&ptr);
1739 }
1740#endif
1741
1742 name_offset = read_u32(&ptr);
1743 d[i].SemanticName = string_data + (name_offset - string_data_offset);
1744 d[i].SemanticIndex = read_u32(&ptr);
1745 d[i].SystemValueType = read_u32(&ptr);
1746 d[i].ComponentType = read_u32(&ptr);
1747 d[i].Register = read_u32(&ptr);
1748 mask = read_u32(&ptr);
1749 d[i].ReadWriteMask = (mask >> 8) & 0xff;
1750 d[i].Mask = mask & 0xff;
1751
1752 if (!stricmp(d[i].SemanticName, "sv_depth"))
1753 d[i].SystemValueType = D3D_NAME_DEPTH;
1754 else if (!stricmp(d[i].SemanticName, "sv_coverage"))
1755 d[i].SystemValueType = D3D_NAME_COVERAGE;
1756 else if (!stricmp(d[i].SemanticName, "sv_depthgreaterequal"))
1757 d[i].SystemValueType = D3D_NAME_DEPTH_GREATER_EQUAL;
1758 else if (!stricmp(d[i].SemanticName, "sv_depthlessequal"))
1759 d[i].SystemValueType = D3D_NAME_DEPTH_LESS_EQUAL;
1760 else if (!stricmp(d[i].SemanticName, "sv_target"))
1761 d[i].SystemValueType = D3D_NAME_TARGET;
1762 }
1763
1764 s->elements = d;
1765 s->element_count = count;
1766 s->string_data = string_data;
1767
1768 return S_OK;
1769}
@ D3D_NAME_TARGET
Definition: d3dcommon.idl:656
@ D3D_NAME_DEPTH_GREATER_EQUAL
Definition: d3dcommon.idl:659
@ D3D_NAME_DEPTH_LESS_EQUAL
Definition: d3dcommon.idl:660
@ D3D_NAME_DEPTH
Definition: d3dcommon.idl:657
@ D3D_NAME_COVERAGE
Definition: d3dcommon.idl:658
@ D3D_MIN_PRECISION_DEFAULT
Definition: d3dcommon.idl:523
#define TAG_ISGN
#define TAG_OSGN
#define TAG_OSG5
#define TAG_PCSG
size_t const element_size
Definition: debug_heap.cpp:510
D3DCOMPILER_SIGNATURE_ELEMENT_SIZE
Definition: reflection.c:46
#define stricmp(_String1, _String2)
Definition: compat.h:24
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLenum GLint GLuint mask
Definition: glext.h:6028
#define d
Definition: ke_i.h:81
static __inline const char * debugstr_fourcc(unsigned int cc)
Definition: debug.h:397
Definition: parser.c:56

Referenced by d3dcompiler_shader_reflection_init().

◆ d3dcompiler_parse_stat()

static HRESULT d3dcompiler_parse_stat ( struct d3dcompiler_shader_reflection *  r,
const char *  data,
size_t  data_size 
)
static

Definition at line 1126 of file reflection.c.

1127{
1128 const char *ptr = data;
1129 size_t size = data_size >> 2;
1130
1131 TRACE("Size %Iu.\n", size);
1132
1133 r->instruction_count = read_u32(&ptr);
1134 TRACE("InstructionCount: %u.\n", r->instruction_count);
1135
1136 r->temp_register_count = read_u32(&ptr);
1137 TRACE("TempRegisterCount: %u.\n", r->temp_register_count);
1138
1139 r->def_count = read_u32(&ptr);
1140 TRACE("DefCount: %u.\n", r->def_count);
1141
1142 r->dcl_count = read_u32(&ptr);
1143 TRACE("DclCount: %u.\n", r->dcl_count);
1144
1145 r->float_instruction_count = read_u32(&ptr);
1146 TRACE("FloatInstructionCount: %u.\n", r->float_instruction_count);
1147
1148 r->int_instruction_count = read_u32(&ptr);
1149 TRACE("IntInstructionCount: %u.\n", r->int_instruction_count);
1150
1151 r->uint_instruction_count = read_u32(&ptr);
1152 TRACE("UintInstructionCount: %u.\n", r->uint_instruction_count);
1153
1154 r->static_flow_control_count = read_u32(&ptr);
1155 TRACE("StaticFlowControlCount: %u.\n", r->static_flow_control_count);
1156
1157 r->dynamic_flow_control_count = read_u32(&ptr);
1158 TRACE("DynamicFlowControlCount: %u.\n", r->dynamic_flow_control_count);
1159
1160 r->macro_instruction_count = read_u32(&ptr);
1161 TRACE("MacroInstructionCount: %u.\n", r->macro_instruction_count);
1162
1163 r->temp_array_count = read_u32(&ptr);
1164 TRACE("TempArrayCount: %u.\n", r->temp_array_count);
1165
1166 r->array_instruction_count = read_u32(&ptr);
1167 TRACE("ArrayInstructionCount: %u.\n", r->array_instruction_count);
1168
1169 r->cut_instruction_count = read_u32(&ptr);
1170 TRACE("CutInstructionCount: %u.\n", r->cut_instruction_count);
1171
1172 r->emit_instruction_count = read_u32(&ptr);
1173 TRACE("EmitInstructionCount: %u.\n", r->emit_instruction_count);
1174
1175 r->texture_normal_instructions = read_u32(&ptr);
1176 TRACE("TextureNormalInstructions: %u.\n", r->texture_normal_instructions);
1177
1178 r->texture_load_instructions = read_u32(&ptr);
1179 TRACE("TextureLoadInstructions: %u.\n", r->texture_load_instructions);
1180
1181 r->texture_comp_instructions = read_u32(&ptr);
1182 TRACE("TextureCompInstructions: %u.\n", r->texture_comp_instructions);
1183
1184 r->texture_bias_instructions = read_u32(&ptr);
1185 TRACE("TextureBiasInstructions: %u.\n", r->texture_bias_instructions);
1186
1187 r->texture_gradient_instructions = read_u32(&ptr);
1188 TRACE("TextureGradientInstructions: %u.\n", r->texture_gradient_instructions);
1189
1190 r->mov_instruction_count = read_u32(&ptr);
1191 TRACE("MovInstructionCount: %u.\n", r->mov_instruction_count);
1192
1193 skip_u32_unknown(&ptr, 1);
1194
1195 r->conversion_instruction_count = read_u32(&ptr);
1196 TRACE("ConversionInstructionCount: %u.\n", r->conversion_instruction_count);
1197
1198 skip_u32_unknown(&ptr, 1);
1199
1200 r->input_primitive = read_u32(&ptr);
1201 TRACE("InputPrimitive: %x.\n", r->input_primitive);
1202
1203 r->gs_output_topology = read_u32(&ptr);
1204 TRACE("GSOutputTopology: %x.\n", r->gs_output_topology);
1205
1206 r->gs_max_output_vertex_count = read_u32(&ptr);
1207 TRACE("GSMaxOutputVertexCount: %u.\n", r->gs_max_output_vertex_count);
1208
1209 skip_u32_unknown(&ptr, 2);
1210
1211 /* old dx10 stat size */
1212 if (size == 28) return S_OK;
1213
1214 skip_u32_unknown(&ptr, 1);
1215
1216 /* dx10 stat size */
1217 if (size == 29) return S_OK;
1218
1219 skip_u32_unknown(&ptr, 1);
1220
1221 r->c_control_points = read_u32(&ptr);
1222 TRACE("cControlPoints: %u.\n", r->c_control_points);
1223
1224 r->hs_output_primitive = read_u32(&ptr);
1225 TRACE("HSOutputPrimitive: %x.\n", r->hs_output_primitive);
1226
1227 r->hs_partitioning = read_u32(&ptr);
1228 TRACE("HSPartitioning: %x.\n", r->hs_partitioning);
1229
1230 r->tessellator_domain = read_u32(&ptr);
1231 TRACE("TessellatorDomain: %x.\n", r->tessellator_domain);
1232
1233 skip_u32_unknown(&ptr, 3);
1234
1235 /* dx11 stat size */
1236 if (size == 37) return S_OK;
1237
1238 FIXME("Unhandled size %Iu.\n", size);
1239
1240 return E_FAIL;
1241}

Referenced by d3dcompiler_shader_reflection_init().

◆ d3dcompiler_parse_type()

static HRESULT d3dcompiler_parse_type ( struct d3dcompiler_shader_reflection_type *  type,
const char *  data,
uint32_t  offset 
)
static

Definition at line 1273 of file reflection.c.

1274{
1275 const char *ptr = data + offset;
1276 uint32_t temp;
1278 unsigned int i;
1280 HRESULT hr;
1281 uint32_t member_offset;
1282
1283 desc = &type->desc;
1284
1285 temp = read_u32(&ptr);
1286 desc->Class = temp & 0xffff;
1287 desc->Type = temp >> 16;
1288 TRACE("Class %s, Type %s\n", debug_d3dcompiler_shader_variable_class(desc->Class),
1290
1291 temp = read_u32(&ptr);
1292 desc->Rows = temp & 0xffff;
1293 desc->Columns = temp >> 16;
1294 TRACE("Rows %u, Columns %u\n", desc->Rows, desc->Columns);
1295
1296 temp = read_u32(&ptr);
1297 desc->Elements = temp & 0xffff;
1298 desc->Members = temp >> 16;
1299 TRACE("Elements %u, Members %u\n", desc->Elements, desc->Members);
1300
1301 member_offset = read_u32(&ptr);
1302 TRACE("Member Offset %u.\n", member_offset);
1303
1304 if ((type->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500)
1305 skip_u32_unknown(&ptr, 4);
1306
1307 if (desc->Members)
1308 {
1309 const char *ptr2 = data + member_offset;
1310
1311 members = calloc(desc->Members, sizeof(*members));
1312 if (!members)
1313 {
1314 ERR("Failed to allocate type memory.\n");
1315 return E_OUTOFMEMORY;
1316 }
1317
1318 for (i = 0; i < desc->Members; ++i)
1319 {
1320 hr = d3dcompiler_parse_type_members(type->reflection, &members[i], data, &ptr2);
1321 if (hr != S_OK)
1322 {
1323 FIXME("Failed to parse type members.\n");
1324 goto err_out;
1325 }
1326 }
1327 }
1328
1329#if D3D_COMPILER_VERSION
1330 if ((type->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500)
1331 {
1332 offset = read_u32(&ptr);
1333 if (!copy_name(data + offset, &type->name))
1334 {
1335 ERR("Failed to copy name.\n");
1336 free(members);
1337 return E_OUTOFMEMORY;
1338 }
1339 desc->Name = type->name;
1340 TRACE("Type name: %s.\n", debugstr_a(type->name));
1341 }
1342#endif
1343
1344 type->members = members;
1345
1346 return S_OK;
1347
1348err_out:
1349 for (i = 0; i < desc->Members; ++i)
1350 {
1351 free_type_member(&members[i]);
1352 }
1353 free(members);
1354 return hr;
1355}
const char * debug_d3dcompiler_shader_variable_type(D3D_SHADER_VARIABLE_TYPE t)
Definition: utils.c:50
const char * debug_d3dcompiler_shader_variable_class(D3D_SHADER_VARIABLE_CLASS c)
Definition: utils.c:32
static void free_type_member(struct d3dcompiler_shader_reflection_type_member *member)
Definition: reflection.c:242
static HRESULT d3dcompiler_parse_type_members(struct d3dcompiler_shader_reflection *ref, struct d3dcompiler_shader_reflection_type_member *member, const char *data, const char **ptr)
Definition: reflection.c:1243
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by get_reflection_type().

◆ d3dcompiler_parse_type_members()

static HRESULT d3dcompiler_parse_type_members ( struct d3dcompiler_shader_reflection *  ref,
struct d3dcompiler_shader_reflection_type_member *  member,
const char *  data,
const char **  ptr 
)
static

Definition at line 1243 of file reflection.c.

1245{
1247
1248 offset = read_u32(ptr);
1249 if (!copy_name(data + offset, &member->name))
1250 {
1251 ERR("Failed to copy name.\n");
1252 return E_OUTOFMEMORY;
1253 }
1254 TRACE("Member name: %s.\n", debugstr_a(member->name));
1255
1256 offset = read_u32(ptr);
1257 TRACE("Member type offset: %x.\n", offset);
1258
1260 if (!member->type)
1261 {
1262 ERR("Failed to get member type\n");
1263 free(member->name);
1264 return E_FAIL;
1265 }
1266
1267 member->offset = read_u32(ptr);
1268 TRACE("Member offset %x.\n", member->offset);
1269
1270 return S_OK;
1271}
static struct d3dcompiler_shader_reflection_type * get_reflection_type(struct d3dcompiler_shader_reflection *reflection, const char *data, uint32_t offset)
Definition: reflection.c:1357
char name[MAX_NAME_LEN]
DWORD type
Definition: send.c:48

Referenced by d3dcompiler_parse_type().

◆ d3dcompiler_parse_variables()

static HRESULT d3dcompiler_parse_variables ( struct d3dcompiler_shader_reflection_constant_buffer *  cb,
const char *  data,
size_t  data_size,
const char *  ptr 
)
static

Definition at line 1396 of file reflection.c.

1398{
1400 unsigned int i;
1401 HRESULT hr;
1402
1403 variables = calloc(cb->variable_count, sizeof(*variables));
1404 if (!variables)
1405 {
1406 ERR("Failed to allocate variables memory.\n");
1407 return E_OUTOFMEMORY;
1408 }
1409
1410 for (i = 0; i < cb->variable_count; i++)
1411 {
1412 struct d3dcompiler_shader_reflection_variable *v = &variables[i];
1414
1415 v->ID3D11ShaderReflectionVariable_iface.lpVtbl = &d3dcompiler_shader_reflection_variable_vtbl;
1416 v->constant_buffer = cb;
1417
1418 offset = read_u32(&ptr);
1419 if (!copy_name(data + offset, &v->name))
1420 {
1421 ERR("Failed to copy name.\n");
1422 hr = E_OUTOFMEMORY;
1423 goto err_out;
1424 }
1425 TRACE("Variable name: %s.\n", debugstr_a(v->name));
1426
1427 v->start_offset = read_u32(&ptr);
1428 TRACE("Variable offset: %u\n", v->start_offset);
1429
1430 v->size = read_u32(&ptr);
1431 TRACE("Variable size: %u\n", v->size);
1432
1433 v->flags = read_u32(&ptr);
1434 TRACE("Variable flags: %u\n", v->flags);
1435
1436 offset = read_u32(&ptr);
1437 TRACE("Variable type offset: %x.\n", offset);
1438 v->type = get_reflection_type(cb->reflection, data, offset);
1439 if (!v->type)
1440 {
1441 ERR("Failed to get type.\n");
1442 hr = E_FAIL;
1443 goto err_out;
1444 }
1445
1446 offset = read_u32(&ptr);
1447 TRACE("Variable default value offset: %x.\n", offset);
1448 if (!copy_value(data + offset, &v->default_value, offset ? v->size : 0))
1449 {
1450 ERR("Failed to copy name.\n");
1451 hr = E_OUTOFMEMORY;
1452 goto err_out;
1453 }
1454
1455 if ((cb->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500)
1456 skip_u32_unknown(&ptr, 4);
1457 }
1458
1459 cb->variables = variables;
1460
1461 return S_OK;
1462
1463err_out:
1464 for (i = 0; i < cb->variable_count; i++)
1465 {
1466 free_variable(&variables[i]);
1467 }
1468 free(variables);
1469 return hr;
1470}
static const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflection_variable_vtbl
Definition: reflection.c:185
static BOOL copy_value(const char *ptr, void **value, uint32_t size)
Definition: reflection.c:218
static void free_variable(struct d3dcompiler_shader_reflection_variable *var)
Definition: reflection.c:278
const GLdouble * v
Definition: gl.h:2040

Referenced by d3dcompiler_parse_rdef().

◆ d3dcompiler_shader_reflection_AddRef()

static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_AddRef ( ID3D11ShaderReflection *  iface)
static

Definition at line 368 of file reflection.c.

369{
372
373 TRACE("%p increasing refcount to %lu.\n", This, refcount);
374
375 return refcount;
376}
#define InterlockedIncrement
Definition: armddk.h:53
static struct d3dcompiler_shader_reflection * impl_from_ID3D11ShaderReflection(ID3D11ShaderReflection *iface)
Definition: reflection.c:344
uint32_t ULONG
Definition: typedefs.h:59

◆ d3dcompiler_shader_reflection_constant_buffer_GetDesc()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetDesc ( ID3D11ShaderReflectionConstantBuffer *  iface,
D3D11_SHADER_BUFFER_DESC *  desc 
)
static

Definition at line 774 of file reflection.c.

776{
778
779 TRACE("iface %p, desc %p\n", iface, desc);
780
782 {
783 WARN("Null constant buffer specified\n");
784 return E_FAIL;
785 }
786
787 if (!desc)
788 {
789 WARN("Invalid argument specified\n");
790 return E_FAIL;
791 }
792
793 desc->Name = This->name;
794 desc->Type = This->type;
795 desc->Variables = This->variable_count;
796 desc->Size = This->size;
797 desc->uFlags = This->flags;
798
799 return S_OK;
800}
static struct d3dcompiler_shader_reflection_constant_buffer * impl_from_ID3D11ShaderReflectionConstantBuffer(ID3D11ShaderReflectionConstantBuffer *iface)
Definition: reflection.c:769
static struct d3dcompiler_shader_reflection_constant_buffer null_constant_buffer
Definition: reflection.c:189

◆ d3dcompiler_shader_reflection_constant_buffer_GetVariableByIndex()

static ID3D11ShaderReflectionVariable *STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByIndex ( ID3D11ShaderReflectionConstantBuffer *  iface,
UINT  index 
)
static

Definition at line 802 of file reflection.c.

804{
806
807 TRACE("iface %p, index %u\n", iface, index);
808
809 if (index >= This->variable_count)
810 {
811 WARN("Invalid index specified\n");
812 return &null_variable.ID3D11ShaderReflectionVariable_iface;
813 }
814
815 return &This->variables[index].ID3D11ShaderReflectionVariable_iface;
816}
#define index(s, c)
Definition: various.h:29
static struct d3dcompiler_shader_reflection_variable null_variable
Definition: reflection.c:197
GLuint index
Definition: glext.h:6031

◆ d3dcompiler_shader_reflection_constant_buffer_GetVariableByName()

static ID3D11ShaderReflectionVariable *STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByName ( ID3D11ShaderReflectionConstantBuffer *  iface,
const char *  name 
)
static

Definition at line 818 of file reflection.c.

820{
822 unsigned int i;
823
824 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
825
826 if (!name)
827 {
828 WARN("Invalid argument specified\n");
829 return &null_variable.ID3D11ShaderReflectionVariable_iface;
830 }
831
832 for (i = 0; i < This->variable_count; ++i)
833 {
834 struct d3dcompiler_shader_reflection_variable *v = &This->variables[i];
835
836 if (!strcmp(v->name, name))
837 {
838 TRACE("Returning ID3D11ShaderReflectionVariable %p.\n", v);
839 return &v->ID3D11ShaderReflectionVariable_iface;
840 }
841 }
842
843 WARN("Invalid name specified\n");
844
845 return &null_variable.ID3D11ShaderReflectionVariable_iface;
846}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324

◆ d3dcompiler_shader_reflection_GetConstantBufferByIndex()

static struct ID3D11ShaderReflectionConstantBuffer *STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByIndex ( ID3D11ShaderReflection *  iface,
UINT  index 
)
static

Definition at line 452 of file reflection.c.

454{
456
457 TRACE("iface %p, index %u\n", iface, index);
458
459 if (index >= This->constant_buffer_count)
460 {
461 WARN("Invalid argument specified\n");
462 return &null_constant_buffer.ID3D11ShaderReflectionConstantBuffer_iface;
463 }
464
465 return &This->constant_buffers[index].ID3D11ShaderReflectionConstantBuffer_iface;
466}

◆ d3dcompiler_shader_reflection_GetConstantBufferByName()

static struct ID3D11ShaderReflectionConstantBuffer *STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByName ( ID3D11ShaderReflection *  iface,
const char *  name 
)
static

Definition at line 468 of file reflection.c.

470{
472 unsigned int i;
473
474 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
475
476 if (!name)
477 {
478 WARN("Invalid argument specified\n");
479 return &null_constant_buffer.ID3D11ShaderReflectionConstantBuffer_iface;
480 }
481
482 for (i = 0; i < This->constant_buffer_count; ++i)
483 {
484 struct d3dcompiler_shader_reflection_constant_buffer *d = &This->constant_buffers[i];
485
486 if (!strcmp(d->name, name))
487 {
488 TRACE("Returning ID3D11ShaderReflectionConstantBuffer %p.\n", d);
489 return &d->ID3D11ShaderReflectionConstantBuffer_iface;
490 }
491 }
492
493 WARN("Invalid name specified\n");
494
495 return &null_constant_buffer.ID3D11ShaderReflectionConstantBuffer_iface;
496}
char * name
Definition: wpp.c:52

◆ d3dcompiler_shader_reflection_GetDesc()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc ( ID3D11ShaderReflection *  iface,
D3D11_SHADER_DESC *  desc 
)
static

Definition at line 396 of file reflection.c.

397{
399
400 FIXME("iface %p, desc %p partial stub!\n", iface, desc);
401
402 if (!desc)
403 {
404 WARN("Invalid argument specified\n");
405 return E_FAIL;
406 }
407
408 desc->Version = reflection->version;
409 desc->Creator = reflection->creator;
410 desc->Flags = reflection->flags;
411 desc->ConstantBuffers = reflection->constant_buffer_count;
412 desc->BoundResources = reflection->bound_resource_count;
413 desc->InputParameters = reflection->isgn ? reflection->isgn->element_count : 0;
414 desc->OutputParameters = reflection->osgn ? reflection->osgn->element_count : 0;
415 desc->InstructionCount = reflection->instruction_count;
416 desc->TempRegisterCount = reflection->temp_register_count;
417 desc->TempArrayCount = reflection->temp_array_count;
418 desc->DefCount = reflection->def_count;
419 desc->DclCount = reflection->dcl_count;
420 desc->TextureNormalInstructions = reflection->texture_normal_instructions;
421 desc->TextureLoadInstructions = reflection->texture_load_instructions;
422 desc->TextureCompInstructions = reflection->texture_comp_instructions;
423 desc->TextureBiasInstructions = reflection->texture_bias_instructions;
424 desc->TextureGradientInstructions = reflection->texture_gradient_instructions;
425 desc->FloatInstructionCount = reflection->float_instruction_count;
426 desc->IntInstructionCount = reflection->int_instruction_count;
427 desc->UintInstructionCount = reflection->uint_instruction_count;
428 desc->StaticFlowControlCount = reflection->static_flow_control_count;
429 desc->DynamicFlowControlCount = reflection->dynamic_flow_control_count;
430 desc->MacroInstructionCount = reflection->macro_instruction_count;
431 desc->ArrayInstructionCount = reflection->array_instruction_count;
432 desc->CutInstructionCount = reflection->cut_instruction_count;
433 desc->EmitInstructionCount = reflection->emit_instruction_count;
434 desc->GSOutputTopology = reflection->gs_output_topology;
435 desc->GSMaxOutputVertexCount = reflection->gs_max_output_vertex_count;
436#if D3D_COMPILER_VERSION
437 desc->InputPrimitive = reflection->input_primitive;
438 desc->PatchConstantParameters = reflection->pcsg ? reflection->pcsg->element_count : 0;
439 desc->cGSInstanceCount = 0;
440 desc->cControlPoints = reflection->c_control_points;
441 desc->HSOutputPrimitive = reflection->hs_output_primitive;
442 desc->HSPartitioning = reflection->hs_partitioning;
443 desc->TessellatorDomain = reflection->tessellator_domain;
444 desc->cBarrierInstructions = 0;
445 desc->cInterlockedInstructions = 0;
446 desc->cTextureStoreInstructions = 0;
447#endif
448
449 return S_OK;
450}
struct d3dcompiler_shader_signature * osgn
Definition: reflection.c:174
D3D_TESSELLATOR_OUTPUT_PRIMITIVE hs_output_primitive
Definition: reflection.c:166
struct d3dcompiler_shader_signature * pcsg
Definition: reflection.c:175
D3D_PRIMITIVE_TOPOLOGY gs_output_topology
Definition: reflection.c:145
D3D_TESSELLATOR_PARTITIONING hs_partitioning
Definition: reflection.c:167
struct d3dcompiler_shader_signature * isgn
Definition: reflection.c:173
D3D_TESSELLATOR_DOMAIN tessellator_domain
Definition: reflection.c:168

◆ d3dcompiler_shader_reflection_GetInputParameterDesc()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameterDesc ( ID3D11ShaderReflection *  iface,
UINT  index,
D3D11_SIGNATURE_PARAMETER_DESC *  desc 
)
static

Definition at line 518 of file reflection.c.

520{
522
523 TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
524
525 if (!desc || !reflection->isgn || index >= reflection->isgn->element_count)
526 {
527 WARN("Invalid argument specified\n");
528 return E_INVALIDARG;
529 }
530
531 *desc = reflection->isgn->elements[index];
532
533 return S_OK;
534}

◆ d3dcompiler_shader_reflection_GetOutputParameterDesc()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParameterDesc ( ID3D11ShaderReflection *  iface,
UINT  index,
D3D11_SIGNATURE_PARAMETER_DESC *  desc 
)
static

Definition at line 536 of file reflection.c.

538{
540
541 TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
542
543 if (!desc || !reflection->osgn || index >= reflection->osgn->element_count)
544 {
545 WARN("Invalid argument specified\n");
546 return E_INVALIDARG;
547 }
548
549 *desc = reflection->osgn->elements[index];
550
551 return S_OK;
552}

◆ d3dcompiler_shader_reflection_GetResourceBindingDesc()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDesc ( ID3D11ShaderReflection *  iface,
UINT  index,
D3D11_SHADER_INPUT_BIND_DESC *  desc 
)
static

Definition at line 498 of file reflection.c.

500{
502
503 TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
504
505 if (!desc || index >= reflection->bound_resource_count)
506 {
507 WARN("Invalid argument specified\n");
508 return E_INVALIDARG;
509 }
510
511 memcpy(desc, &reflection->bound_resources[index],
514
515 return S_OK;
516}
D3D12_SHADER_INPUT_BIND_DESC * bound_resources
Definition: reflection.c:177
enum D3DCOMPILER_REFLECTION_VERSION interface_version
Definition: reflection.c:132

◆ d3dcompiler_shader_reflection_init()

static HRESULT d3dcompiler_shader_reflection_init ( struct d3dcompiler_shader_reflection *  reflection,
const void *  data,
SIZE_T  data_size 
)
static

Definition at line 1847 of file reflection.c.

1849{
1850 const struct vkd3d_shader_code src_dxbc = {.code = data, .size = data_size};
1851 struct vkd3d_shader_dxbc_desc src_dxbc_desc;
1852 HRESULT hr = S_OK;
1853 unsigned int i;
1854 int ret;
1855
1857
1858 if ((ret = vkd3d_shader_parse_dxbc(&src_dxbc, 0, &src_dxbc_desc, NULL)) < 0)
1859 {
1860 WARN("Failed to parse reflection, ret %d.\n", ret);
1861 return E_FAIL;
1862 }
1863
1864 for (i = 0; i < src_dxbc_desc.section_count; ++i)
1865 {
1866 const struct vkd3d_shader_dxbc_section_desc *section = &src_dxbc_desc.sections[i];
1867
1868 switch (section->tag)
1869 {
1870 case TAG_RDEF:
1871 hr = d3dcompiler_parse_rdef(reflection, section->data.code, section->data.size);
1872 if (FAILED(hr))
1873 {
1874 WARN("Failed to parse RDEF section.\n");
1875 goto err_out;
1876 }
1877 break;
1878
1879 case TAG_ISGN:
1880 reflection->isgn = calloc(1, sizeof(*reflection->isgn));
1881 if (!reflection->isgn)
1882 {
1883 ERR("Failed to allocate ISGN memory.\n");
1884 hr = E_OUTOFMEMORY;
1885 goto err_out;
1886 }
1887
1889 if (FAILED(hr))
1890 {
1891 WARN("Failed to parse section ISGN.\n");
1892 goto err_out;
1893 }
1894 break;
1895
1896 case TAG_OSG5:
1897 case TAG_OSGN:
1898 reflection->osgn = calloc(1, sizeof(*reflection->osgn));
1899 if (!reflection->osgn)
1900 {
1901 ERR("Failed to allocate OSGN memory.\n");
1902 hr = E_OUTOFMEMORY;
1903 goto err_out;
1904 }
1905
1907 if (FAILED(hr))
1908 {
1909 WARN("Failed to parse section OSGN.\n");
1910 goto err_out;
1911 }
1912 break;
1913
1914 case TAG_PCSG:
1915 reflection->pcsg = calloc(1, sizeof(*reflection->pcsg));
1916 if (!reflection->pcsg)
1917 {
1918 ERR("Failed to allocate PCSG memory.\n");
1919 hr = E_OUTOFMEMORY;
1920 goto err_out;
1921 }
1922
1924 if (FAILED(hr))
1925 {
1926 WARN("Failed to parse section PCSG.\n");
1927 goto err_out;
1928 }
1929 break;
1930
1931 case TAG_SHEX:
1932 case TAG_SHDR:
1933 hr = d3dcompiler_parse_shdr(reflection, section->data.code, section->data.size);
1934 if (FAILED(hr))
1935 {
1936 WARN("Failed to parse SHDR section.\n");
1937 goto err_out;
1938 }
1939 break;
1940
1941 case TAG_STAT:
1942 hr = d3dcompiler_parse_stat(reflection, section->data.code, section->data.size);
1943 if (FAILED(hr))
1944 {
1945 WARN("Failed to parse section STAT.\n");
1946 goto err_out;
1947 }
1948 break;
1949
1950 default:
1951 FIXME("Unhandled section %s!\n", debugstr_fourcc(section->tag));
1952 break;
1953 }
1954 }
1955
1956 vkd3d_shader_free_dxbc(&src_dxbc_desc);
1957
1958 return hr;
1959
1960err_out:
1961 reflection_cleanup(reflection);
1962 vkd3d_shader_free_dxbc(&src_dxbc_desc);
1963
1964 return hr;
1965}
#define TAG_SHEX
#define TAG_SHDR
#define TAG_STAT
#define TAG_RDEF
static HRESULT d3dcompiler_parse_stat(struct d3dcompiler_shader_reflection *r, const char *data, size_t data_size)
Definition: reflection.c:1126
static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, const char *data, size_t data_size)
Definition: reflection.c:1472
static HRESULT d3dcompiler_parse_shdr(struct d3dcompiler_shader_reflection *r, const char *data, size_t data_size)
Definition: reflection.c:1780
static int d3dcompiler_shader_reflection_type_compare(const void *key, const struct wine_rb_entry *entry)
Definition: reflection.c:234
static void reflection_cleanup(struct d3dcompiler_shader_reflection *ref)
Definition: reflection.c:303
static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *s, const struct vkd3d_shader_dxbc_section_desc *section)
Definition: reflection.c:1673
return ret
Definition: mutex.c:147
#define wine_rb_init
Definition: rbtree.h:406
struct wine_rb_tree types
Definition: reflection.c:179
const void * code
Definition: vkd3d_shader.h:413
VKD3D_SHADER_API void vkd3d_shader_free_dxbc(struct vkd3d_shader_dxbc_desc *dxbc)
Definition: dxbc.c:290
VKD3D_SHADER_API int vkd3d_shader_parse_dxbc(const struct vkd3d_shader_code *dxbc, uint32_t flags, struct vkd3d_shader_dxbc_desc *desc, char **messages)
Definition: dxbc.c:320

Referenced by D3D10ReflectShader().

◆ d3dcompiler_shader_reflection_QueryInterface()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_QueryInterface ( ID3D11ShaderReflection *  iface,
REFIID  riid,
void **  object 
)
static

Definition at line 349 of file reflection.c.

350{
351 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
352
355 || (D3D_COMPILER_VERSION >= 47 && IsEqualGUID(riid, &IID_ID3D12ShaderReflection)))
356 {
357 IUnknown_AddRef(iface);
358 *object = iface;
359 return S_OK;
360 }
361
362 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
363
364 *object = NULL;
365 return E_NOINTERFACE;
366}
const GUID IID_IUnknown
#define IID_ID3D11ShaderReflection
Definition: reflection.c:34
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ d3dcompiler_shader_reflection_Release()

static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release ( ID3D11ShaderReflection *  iface)
static

Definition at line 378 of file reflection.c.

379{
382
383 TRACE("%p decreasing refcount to %lu.\n", This, refcount);
384
385 if (!refcount)
386 {
388 free(This);
389 }
390
391 return refcount;
392}
#define InterlockedDecrement
Definition: armddk.h:52

◆ d3dcompiler_shader_reflection_type_compare()

static int d3dcompiler_shader_reflection_type_compare ( const void *  key,
const struct wine_rb_entry *  entry 
)
static

Definition at line 234 of file reflection.c.

235{
237 const uint32_t *id = key;
238
239 return *id - t->id;
240}
GLdouble GLdouble t
Definition: gl.h:2047
uint32_t entry
Definition: isohybrid.c:63
#define WINE_RB_ENTRY_VALUE
Definition: rbtree.h:414
Definition: copy.c:22

Referenced by d3dcompiler_shader_reflection_init().

◆ d3dcompiler_shader_reflection_type_destroy()

static void d3dcompiler_shader_reflection_type_destroy ( struct wine_rb_entry *  entry,
void *  context 
)
static

Definition at line 250 of file reflection.c.

251{
253 unsigned int i;
254
255 TRACE("reflection type %p.\n", t);
256
257 if (t->members)
258 {
259 for (i = 0; i < t->desc.Members; ++i)
260 {
261 free_type_member(&t->members[i]);
262 }
263 free(t->members);
264 }
265
266 free(t->name);
267 free(t);
268}

Referenced by reflection_cleanup().

◆ d3dcompiler_shader_reflection_type_GetDesc()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetDesc ( ID3D11ShaderReflectionType *  iface,
D3D11_SHADER_TYPE_DESC *  desc 
)
static

Definition at line 947 of file reflection.c.

949{
951
952 TRACE("iface %p, desc %p\n", iface, desc);
953
954 if (This == &null_type)
955 {
956 WARN("Null type specified\n");
957 return E_FAIL;
958 }
959
960 if (!desc)
961 {
962 WARN("Invalid argument specified\n");
963 return E_FAIL;
964 }
965
966 *desc = This->desc;
967
968 return S_OK;
969}
static struct d3dcompiler_shader_reflection_type * impl_from_ID3D11ShaderReflectionType(ID3D11ShaderReflectionType *iface)
Definition: reflection.c:942
static struct d3dcompiler_shader_reflection_type null_type
Definition: reflection.c:193

◆ d3dcompiler_shader_reflection_type_GetMemberTypeByIndex()

static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByIndex ( ID3D11ShaderReflectionType *  iface,
UINT  index 
)
static

Definition at line 971 of file reflection.c.

973{
975
976 TRACE("iface %p, index %u\n", iface, index);
977
978 if (index >= This->desc.Members)
979 {
980 WARN("Invalid index specified\n");
981 return &null_type.ID3D11ShaderReflectionType_iface;
982 }
983
984 return &This->members[index].type->ID3D11ShaderReflectionType_iface;
985}

◆ d3dcompiler_shader_reflection_type_GetMemberTypeByName()

static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByName ( ID3D11ShaderReflectionType *  iface,
const char *  name 
)
static

Definition at line 987 of file reflection.c.

989{
991 unsigned int i;
992
993 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
994
995 if (!name)
996 {
997 WARN("Invalid argument specified\n");
998 return &null_type.ID3D11ShaderReflectionType_iface;
999 }
1000
1001 for (i = 0; i < This->desc.Members; ++i)
1002 {
1004
1005 if (!strcmp(member->name, name))
1006 {
1007 TRACE("Returning ID3D11ShaderReflectionType %p.\n", member->type);
1008 return &member->type->ID3D11ShaderReflectionType_iface;
1009 }
1010 }
1011
1012 WARN("Invalid name specified\n");
1013
1014 return &null_type.ID3D11ShaderReflectionType_iface;
1015}

◆ d3dcompiler_shader_reflection_type_GetMemberTypeName()

static const char *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeName ( ID3D11ShaderReflectionType *  iface,
UINT  index 
)
static

Definition at line 1017 of file reflection.c.

1019{
1021
1022 TRACE("iface %p, index %u\n", iface, index);
1023
1024 if (This == &null_type)
1025 {
1026 WARN("Null type specified\n");
1027 return "$Invalid";
1028 }
1029
1030 if (index >= This->desc.Members)
1031 {
1032 WARN("Invalid index specified\n");
1033 return NULL;
1034 }
1035
1036 return This->members[index].name;
1037}

◆ d3dcompiler_shader_reflection_variable_GetDesc()

static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetDesc ( ID3D11ShaderReflectionVariable *  iface,
D3D11_SHADER_VARIABLE_DESC *  desc 
)
static

Definition at line 863 of file reflection.c.

865{
867
868 TRACE("iface %p, desc %p\n", iface, desc);
869
870 if (This == &null_variable)
871 {
872 WARN("Null variable specified\n");
873 return E_FAIL;
874 }
875
876 if (!desc)
877 {
878 WARN("Invalid argument specified\n");
879 return E_FAIL;
880 }
881
882 desc->Name = This->name;
883 desc->StartOffset = This->start_offset;
884 desc->Size = This->size;
885 desc->uFlags = This->flags;
886 desc->DefaultValue = This->default_value;
887
888#if D3D_COMPILER_VERSION
889 /* TODO test and set proper values for texture. */
890 desc->StartTexture = 0xffffffff;
891 desc->TextureSize = 0;
892 desc->StartSampler = 0xffffffff;
893 desc->SamplerSize = 0;
894#endif
895
896 return S_OK;
897}
static struct d3dcompiler_shader_reflection_variable * impl_from_ID3D11ShaderReflectionVariable(ID3D11ShaderReflectionVariable *iface)
Definition: reflection.c:858

◆ d3dcompiler_shader_reflection_variable_GetType()

static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetType ( ID3D11ShaderReflectionVariable *  iface)
static

Definition at line 899 of file reflection.c.

901{
903
904 TRACE("iface %p\n", iface);
905
906 return &This->type->ID3D11ShaderReflectionType_iface;
907}

◆ free_constant_buffer()

static void free_constant_buffer ( struct d3dcompiler_shader_reflection_constant_buffer *  cb)
static

Definition at line 287 of file reflection.c.

288{
289 if (cb->variables)
290 {
291 unsigned int i;
292
293 for (i = 0; i < cb->variable_count; ++i)
294 {
295 free_variable(&cb->variables[i]);
296 }
297 free(cb->variables);
298 }
299
300 free(cb->name);
301}

Referenced by d3dcompiler_parse_rdef(), and reflection_cleanup().

◆ free_signature()

static void free_signature ( struct d3dcompiler_shader_signature *  sig)
static

Definition at line 270 of file reflection.c.

271{
272 TRACE("Free signature %p\n", sig);
273
274 free(sig->elements);
275 free(sig->string_data);
276}
D3D11_SIGNATURE_PARAMETER_DESC * elements
Definition: reflection.c:64

Referenced by ITERATE_AppSearch(), ITERATE_CCPSearch(), and reflection_cleanup().

◆ free_type_member()

static void free_type_member ( struct d3dcompiler_shader_reflection_type_member *  member)
static

Definition at line 242 of file reflection.c.

243{
244 if (member)
245 {
246 free(member->name);
247 }
248}

Referenced by d3dcompiler_parse_type(), and d3dcompiler_shader_reflection_type_destroy().

◆ free_variable()

static void free_variable ( struct d3dcompiler_shader_reflection_variable *  var)
static

Definition at line 278 of file reflection.c.

279{
280 if (var)
281 {
282 free(var->name);
283 free(var->default_value);
284 }
285}
const char * var
Definition: shader.c:5879

Referenced by d3dcompiler_parse_variables(), and free_constant_buffer().

◆ get_reflection_type()

static struct d3dcompiler_shader_reflection_type * get_reflection_type ( struct d3dcompiler_shader_reflection *  reflection,
const char *  data,
uint32_t  offset 
)
static

Definition at line 1357 of file reflection.c.

1358{
1360 struct wine_rb_entry *entry;
1361 HRESULT hr;
1362
1363 entry = wine_rb_get(&reflection->types, &offset);
1364 if (entry)
1365 {
1366 TRACE("Returning existing type.\n");
1368 }
1369
1370 type = calloc(1, sizeof(*type));
1371 if (!type)
1372 return NULL;
1373
1374 type->ID3D11ShaderReflectionType_iface.lpVtbl = &d3dcompiler_shader_reflection_type_vtbl;
1375 type->id = offset;
1376 type->reflection = reflection;
1377
1379 if (FAILED(hr))
1380 {
1381 ERR("Failed to parse type info, hr %#lx.\n", hr);
1382 free(type);
1383 return NULL;
1384 }
1385
1386 if (wine_rb_put(&reflection->types, &offset, &type->entry) == -1)
1387 {
1388 ERR("Failed to insert type entry.\n");
1389 free(type);
1390 return NULL;
1391 }
1392
1393 return type;
1394}
static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type *type, const char *data, uint32_t offset)
Definition: reflection.c:1273
static const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection_type_vtbl
Definition: reflection.c:186
#define wine_rb_entry
Definition: rbtree.h:404
#define wine_rb_put
Definition: rbtree.h:410
#define wine_rb_get
Definition: rbtree.h:409

Referenced by d3dcompiler_parse_type_members(), and d3dcompiler_parse_variables().

◆ impl_from_ID3D11ShaderReflection()

◆ impl_from_ID3D11ShaderReflectionConstantBuffer()

◆ impl_from_ID3D11ShaderReflectionType()

◆ impl_from_ID3D11ShaderReflectionVariable()

static struct d3dcompiler_shader_reflection_variable * impl_from_ID3D11ShaderReflectionVariable ( ID3D11ShaderReflectionVariable *  iface)
inlinestatic

Definition at line 858 of file reflection.c.

859{
860 return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_variable, ID3D11ShaderReflectionVariable_iface);
861}

Referenced by d3dcompiler_shader_reflection_variable_GetDesc(), and d3dcompiler_shader_reflection_variable_GetType().

◆ reflection_cleanup()

static void reflection_cleanup ( struct d3dcompiler_shader_reflection *  ref)
static

Definition at line 303 of file reflection.c.

304{
305 TRACE("Cleanup %p\n", ref);
306
307 if (ref->isgn)
308 {
309 free_signature(ref->isgn);
310 free(ref->isgn);
311 }
312
313 if (ref->osgn)
314 {
315 free_signature(ref->osgn);
316 free(ref->osgn);
317 }
318
319 if (ref->pcsg)
320 {
321 free_signature(ref->pcsg);
322 free(ref->pcsg);
323 }
324
325 if (ref->constant_buffers)
326 {
327 unsigned int i;
328
329 for (i = 0; i < ref->constant_buffer_count; ++i)
330 {
331 free_constant_buffer(&ref->constant_buffers[i]);
332 }
333 }
334
336 free(ref->constant_buffers);
337 free(ref->bound_resources);
338 free(ref->resource_string);
339 free(ref->creator);
340}
static void d3dcompiler_shader_reflection_type_destroy(struct wine_rb_entry *entry, void *context)
Definition: reflection.c:250
static void free_signature(struct d3dcompiler_shader_signature *sig)
Definition: reflection.c:270
#define wine_rb_destroy
Definition: rbtree.h:408

Referenced by d3dcompiler_shader_reflection_init(), and d3dcompiler_shader_reflection_Release().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dcompiler  )

Variable Documentation

◆ d3dcompiler_shader_reflection_constant_buffer_vtbl

static const struct ID3D11ShaderReflectionConstantBufferVtbl d3dcompiler_shader_reflection_constant_buffer_vtbl
static
Initial value:
=
{
}
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetDesc(ID3D11ShaderReflectionConstantBuffer *iface, D3D11_SHADER_BUFFER_DESC *desc)
Definition: reflection.c:774
static ID3D11ShaderReflectionVariable *STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByIndex(ID3D11ShaderReflectionConstantBuffer *iface, UINT index)
Definition: reflection.c:802
static ID3D11ShaderReflectionVariable *STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByName(ID3D11ShaderReflectionConstantBuffer *iface, const char *name)
Definition: reflection.c:818

Definition at line 184 of file reflection.c.

Referenced by d3dcompiler_parse_rdef().

◆ d3dcompiler_shader_reflection_type_vtbl

static const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection_type_vtbl
static
Initial value:
=
{
}
static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByIndex(ID3D11ShaderReflectionType *iface, UINT index)
Definition: reflection.c:971
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetDesc(ID3D11ShaderReflectionType *iface, D3D11_SHADER_TYPE_DESC *desc)
Definition: reflection.c:947
static const char *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeName(ID3D11ShaderReflectionType *iface, UINT index)
Definition: reflection.c:1017
static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByName(ID3D11ShaderReflectionType *iface, const char *name)
Definition: reflection.c:987

Definition at line 186 of file reflection.c.

Referenced by get_reflection_type().

◆ d3dcompiler_shader_reflection_variable_vtbl

static const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflection_variable_vtbl
static
Initial value:
=
{
}
static ID3D11ShaderReflectionType *STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetType(ID3D11ShaderReflectionVariable *iface)
Definition: reflection.c:899
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetDesc(ID3D11ShaderReflectionVariable *iface, D3D11_SHADER_VARIABLE_DESC *desc)
Definition: reflection.c:863

Definition at line 185 of file reflection.c.

Referenced by d3dcompiler_parse_variables().

◆ d3dcompiler_shader_reflection_vtbl

const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl
static
Initial value:
=
{
}
static struct ID3D11ShaderReflectionConstantBuffer *STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByName(ID3D11ShaderReflection *iface, const char *name)
Definition: reflection.c:468
static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_AddRef(ID3D11ShaderReflection *iface)
Definition: reflection.c:368
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDesc(ID3D11ShaderReflection *iface, UINT index, D3D11_SHADER_INPUT_BIND_DESC *desc)
Definition: reflection.c:498
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameterDesc(ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
Definition: reflection.c:518
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParameterDesc(ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
Definition: reflection.c:536
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_QueryInterface(ID3D11ShaderReflection *iface, REFIID riid, void **object)
Definition: reflection.c:349
static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release(ID3D11ShaderReflection *iface)
Definition: reflection.c:378
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11ShaderReflection *iface, D3D11_SHADER_DESC *desc)
Definition: reflection.c:396
static struct ID3D11ShaderReflectionConstantBuffer *STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByIndex(ID3D11ShaderReflection *iface, UINT index)
Definition: reflection.c:452

Definition at line 737 of file reflection.c.

Referenced by D3D10ReflectShader().

◆ null_constant_buffer

◆ null_type

◆ null_variable