diff options
Diffstat (limited to 'src/gallium/state_trackers')
7 files changed, 116 insertions, 13 deletions
diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h index 44fce81079..06a078af6e 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h @@ -75,6 +75,15 @@ struct dxbc_container std::map<unsigned, unsigned> chunk_map; }; +struct dxbc_container_header +{ + unsigned fourcc; + uint32_t unk[4]; + uint32_t one; + uint32_t total_size; + uint32_t chunk_count; +}; + dxbc_container* dxbc_parse(const void* data, int size); std::ostream& operator <<(std::ostream& out, const dxbc_container& container); @@ -98,4 +107,6 @@ struct _D3D11_SIGNATURE_PARAMETER_DESC; typedef struct _D3D11_SIGNATURE_PARAMETER_DESC D3D11_SIGNATURE_PARAMETER_DESC; int dxbc_parse_signature(dxbc_chunk_signature* sig, D3D11_SIGNATURE_PARAMETER_DESC** params); +std::pair<void*, size_t> dxbc_assemble(struct dxbc_chunk_header** chunks, unsigned num_chunks); + #endif /* DXBC_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_assemble.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_assemble.cpp new file mode 100644 index 0000000000..1021a8a1bd --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_assemble.cpp @@ -0,0 +1,59 @@ +/************************************************************************** + * + * Copyright 2010 Luca Barbieri + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include <stdlib.h> +#include <string.h> +#include "dxbc.h" + +std::pair<void*, size_t> dxbc_assemble(struct dxbc_chunk_header** chunks, unsigned num_chunks) +{ + size_t data_size = 0; + for(unsigned i = 0; i < num_chunks; ++i) + data_size += sizeof(uint32_t) + sizeof(dxbc_chunk_header) + bswap_le32(chunks[i]->size); + + size_t total_size = sizeof(dxbc_container_header) + data_size; + dxbc_container_header* header = (dxbc_container_header*)malloc(total_size); + if(!header) + return std::make_pair((void*)0, 0); + + header->fourcc = bswap_le32(FOURCC_DXBC); + memset(header->unk, 0, sizeof(header->unk)); + header->one = bswap_le32(1); + header->total_size = bswap_le32(total_size); + header->chunk_count = num_chunks; + + uint32_t* chunk_offsets = (uint32_t*)(header + 1); + uint32_t off = sizeof(struct dxbc_container_header) + num_chunks * sizeof(uint32_t); + for(unsigned i = 0; i < num_chunks; ++i) + { + chunk_offsets[i] = bswap_le32(off); + unsigned chunk_full_size = sizeof(dxbc_chunk_header) + bswap_le32(chunks[i]->size); + memcpy((char*)header + off, chunks[i], chunk_full_size); + off += chunk_full_size; + } + + return std::make_pair((void*)header, total_size); +} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp index 6b696ae1af..4903e2c3b9 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp @@ -29,26 +29,18 @@ #include <d3d11shader.h> #include <d3dcommon.h> -struct dxbc_container_header -{ - unsigned fourcc; - uint32_t unk[5]; - uint32_t total_size; - uint32_t chunk_count; - uint32_t chunk_offsets[]; -}; - dxbc_container* dxbc_parse(const void* data, int size) { std::auto_ptr<dxbc_container> container(new dxbc_container()); container->data = data; dxbc_container_header* header = (dxbc_container_header*)data; + uint32_t* chunk_offsets = (uint32_t*)(header + 1); if(bswap_le32(header->fourcc) != FOURCC_DXBC) return 0; unsigned num_chunks = bswap_le32(header->chunk_count); for(unsigned i = 0; i < num_chunks; ++i) { - unsigned offset = bswap_le32(header->chunk_offsets[i]); + unsigned offset = bswap_le32(chunk_offsets[i]); dxbc_chunk_header* chunk = (dxbc_chunk_header*)((char*)data + offset); unsigned fourcc = bswap_le32(chunk->fourcc); container->chunk_map[fourcc] = i; @@ -60,12 +52,13 @@ dxbc_container* dxbc_parse(const void* data, int size) dxbc_chunk_header* dxbc_find_chunk(const void* data, int size, unsigned fourcc) { dxbc_container_header* header = (dxbc_container_header*)data; + uint32_t* chunk_offsets = (uint32_t*)(header + 1); if(bswap_le32(header->fourcc) != FOURCC_DXBC) return 0; unsigned num_chunks = bswap_le32(header->chunk_count); for(unsigned i = 0; i < num_chunks; ++i) { - unsigned offset = bswap_le32(header->chunk_offsets[i]); + unsigned offset = bswap_le32(chunk_offsets[i]); dxbc_chunk_header* chunk = (dxbc_chunk_header*)((char*)data + offset); if(bswap_le32(chunk->fourcc) == fourcc) return chunk; diff --git a/src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h b/src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h index a9260acdba..47bf842b7b 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h +++ b/src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h @@ -59,6 +59,7 @@ namespace std { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } #include "galliumdxgi.h" +#include <d3dcommon.h> extern "C" { @@ -1035,4 +1036,37 @@ struct GalliumDXGIDevice : public GalliumMultiPrivateDataComObject<Base, IDXGIDe } }; +COM_INTERFACE(ID3D10Blob, IUnknown); + +/* NOTE: ID3DBlob implementations may come from a Microsoft native DLL + * (e.g. d3dcompiler), or perhaps even from the application itself. + * + * Hence, never try to access the data/size members directly, which is why they are private. + * In internal code, use std::pair<void*, size_t> instead of this class. + */ +class GalliumD3DBlob : public GalliumComObject<ID3DBlob> +{ + void* data; + size_t size; + + GalliumD3DBlob(void* data, size_t size) + : data(data), size(size) + {} + + ~GalliumD3DBlob() + { + free(data); + } +public: + virtual LPVOID STDMETHODCALLTYPE GetBufferPointer() + { + return data; + } + + virtual SIZE_T STDMETHODCALLTYPE GetBufferSize() + { + return size; + } +}; + #endif /* D3D1XSTUTIL_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl b/src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl index 3594bf58f8..71021b8a6c 100644 --- a/src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl @@ -314,6 +314,10 @@ interface ID3D10Blob : IUnknown SIZE_T GetBufferSize(); }; +typedef ID3D10Blob* LPD3D10BLOB; +typedef ID3D10Blob ID3DBlob; +typedef ID3DBlob* LPD3DBLOB; + typedef enum _D3D_INCLUDE_TYPE { D3D_INCLUDE_LOCAL = 0, diff --git a/src/gallium/state_trackers/d3d1x/gd3d10/Makefile b/src/gallium/state_trackers/d3d1x/gd3d10/Makefile index c6cfea25ea..300149d384 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d10/Makefile +++ b/src/gallium/state_trackers/d3d1x/gd3d10/Makefile @@ -6,7 +6,7 @@ GEN_D3D10=perl d3d10.pl include ../Makefile.inc -d3d10.generated.o: d3d10_objects.generated.h d3d10_screen.generated.h d3d10_context.generated.h +d3d10.generated.o: d3d10_objects.generated.h d3d10_screen.generated.h d3d10_context.generated.h d3d10_misc.generated.h d3d10.generated.cpp: ../gd3d11/d3d11.cpp d3d10.pl $(GEN_D3D10) $< > $@ @@ -16,4 +16,5 @@ d3d10_screen.generated.h: ../gd3d11/d3d11_screen.h d3d10.pl $(GEN_D3D10) $< > $@ d3d10_context.generated.h: ../gd3d11/d3d11_context.h d3d10.pl $(GEN_D3D10) $< > $@ - +d3d10_misc.generated.h: ../gd3d11/d3d11_misc.h d3d10.pl + $(GEN_D3D10) $< > $@ diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp index 22cbf150fe..69dfd403f3 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp @@ -214,6 +214,7 @@ struct GalliumD3D11Screen #include "d3d11_objects.h" #include "d3d11_screen.h" #include "d3d11_context.h" +#include "d3d11_misc.h" #if API >= 11 HRESULT STDMETHODCALLTYPE GalliumD3D11DeviceCreate(struct pipe_screen* screen, struct pipe_context* context, BOOL owns_context, unsigned creation_flags, IDXGIAdapter* adapter, ID3D11Device** ppDevice) |