diff --git a/src/gallium/frontends/d3d10umd/D3DKMT.cpp b/src/gallium/frontends/d3d10umd/D3DKMT.cpp index 1649eddc41e8f17fd9e0854acbb8e0c882d94cb5..dc31e9931876cac6ae4e52a80f6da7aa5284415c 100644 --- a/src/gallium/frontends/d3d10umd/D3DKMT.cpp +++ b/src/gallium/frontends/d3d10umd/D3DKMT.cpp @@ -244,7 +244,7 @@ D3DKMTGetMultisampleMethodList(D3DKMT_GETMULTISAMPLEMETHODLIST *pData) EXTERN_C NTSTATUS APIENTRY -D3DKMTPresent(CONST D3DKMT_PRESENT *pData) +D3DKMTPresent(D3DKMT_PRESENT *pData) { LOG_UNSUPPORTED_ENTRYPOINT(); return STATUS_NOT_IMPLEMENTED; @@ -409,7 +409,7 @@ D3DKMTSetVidPnSourceOwner(CONST D3DKMT_SETVIDPNSOURCEOWNER *pData) EXTERN_C NTSTATUS APIENTRY -D3DKMTSetVidPnSourceOwner1(const void *pData) +D3DKMTSetVidPnSourceOwner1(CONST D3DKMT_SETVIDPNSOURCEOWNER1 *pData) { LOG_UNSUPPORTED_ENTRYPOINT(); return STATUS_NOT_IMPLEMENTED; diff --git a/src/gallium/frontends/d3d10umd/Device.cpp b/src/gallium/frontends/d3d10umd/Device.cpp index afca18819ce04f28b23fee9ebdaa57b52a04426c..cd2c6cd9180eb03612500aa8d8475994a2f836fc 100644 --- a/src/gallium/frontends/d3d10umd/Device.cpp +++ b/src/gallium/frontends/d3d10umd/Device.cpp @@ -32,7 +32,7 @@ #include "Draw.h" -#include "Dxgi.h" +#include "DxgiFns.h" #include "InputAssembly.h" #include "OutputMerger.h" #include "Query.h" diff --git a/src/gallium/frontends/d3d10umd/DriverIncludes.h b/src/gallium/frontends/d3d10umd/DriverIncludes.h index e78d46fafc55557f3266e700fdc2a72305827ce6..c7df64042b5b013680ec3c8190cfac7b4b958ded 100644 --- a/src/gallium/frontends/d3d10umd/DriverIncludes.h +++ b/src/gallium/frontends/d3d10umd/DriverIncludes.h @@ -43,12 +43,21 @@ #include -#include "winddk/winddk_compat.h" +#include "winddk_compat.h" //typedef LARGE_INTEGER PHYSICAL_ADDRESS; //typedef __success(return >= 0) LONG NTSTATUS; -#define D3D10DDI_MINOR_HEADER_VERSION 1 +#define D3D10DDI_MINOR_HEADER_VERSION 2 + +/* Unfortunately WinDDK's d3d10umddi.h defines D3D10.x constants as global + * const variables instead of preprocessor defines, causing LINK to fail due + * to duplicate symbols. Include d3d10_1.h to avoid the issue. + */ +#ifdef _MSC_VER +#include +#endif + #include #include "Debug.h" diff --git a/src/gallium/frontends/d3d10umd/Dxgi.cpp b/src/gallium/frontends/d3d10umd/DxgiFns.cpp similarity index 97% rename from src/gallium/frontends/d3d10umd/Dxgi.cpp rename to src/gallium/frontends/d3d10umd/DxgiFns.cpp index 253f81ed283b55dd4bff29df8658f386c08cbc95..cd844a2b0fa19e23c46da0ddc3a92a9a2c9d81b6 100644 --- a/src/gallium/frontends/d3d10umd/Dxgi.cpp +++ b/src/gallium/frontends/d3d10umd/DxgiFns.cpp @@ -26,13 +26,13 @@ **************************************************************************/ /* - * Dxgi.cpp -- + * DxgiFns.cpp -- * DXGI related functions. */ #include -#include "Dxgi.h" +#include "DxgiFns.h" #include "Format.h" #include "State.h" @@ -97,11 +97,11 @@ _Present(DXGI_DDI_ARG_PRESENT *pPresentData) void *map; struct pipe_transfer *transfer; - map = pipe_transfer_map(pipe, - pSrcResource->resource, - 0, 0, PIPE_MAP_READ, - 0, 0, w, h, - &transfer); + map = pipe_texture_map(pipe, + pSrcResource->resource, + 0, 0, PIPE_MAP_READ, + 0, 0, w, h, + &transfer); if (map) { BITMAPINFO bmi; @@ -172,7 +172,7 @@ _Present(DXGI_DDI_ARG_PRESENT *pPresentData) DeleteDC(hdcMem); DeleteObject(hBmp); - pipe_transfer_unmap(pipe, transfer); + pipe_texture_unmap(pipe, transfer); } ReleaseDC(hWnd, hDC); diff --git a/src/gallium/frontends/d3d10umd/Dxgi.h b/src/gallium/frontends/d3d10umd/DxgiFns.h similarity index 96% rename from src/gallium/frontends/d3d10umd/Dxgi.h rename to src/gallium/frontends/d3d10umd/DxgiFns.h index dedc2542d6ab016111a78b713b9cbe54581ba92a..3689faa307c07deb62c3f5c39b4788dd8d60cb35 100644 --- a/src/gallium/frontends/d3d10umd/Dxgi.h +++ b/src/gallium/frontends/d3d10umd/DxgiFns.h @@ -26,8 +26,8 @@ **************************************************************************/ /* - * Dxgi.h -- - * Functions that manipulate GPU resources. + * DxgiFns.h -- + * DXGI related functions */ #ifndef WRAP_DXGI_H diff --git a/src/gallium/frontends/d3d10umd/Resource.cpp b/src/gallium/frontends/d3d10umd/Resource.cpp index a7910d2e3cf186597bb35d7c5a98464c4e844cf7..3dd91365b23e5608108a0e09e1296cb0a7bc65df 100644 --- a/src/gallium/frontends/d3d10umd/Resource.cpp +++ b/src/gallium/frontends/d3d10umd/Resource.cpp @@ -270,6 +270,7 @@ CreateResource(D3D10DDI_HDEVICE hDevice, // IN templat.target = translate_texture_target( pCreateResource->ResourceDimension, pCreateResource->ArraySize ); + pResource->buffer = templat.target == PIPE_BUFFER; if (pCreateResource->Format == DXGI_FORMAT_UNKNOWN) { assert(pCreateResource->ResourceDimension == D3D10DDIRESOURCE_BUFFER); @@ -315,37 +316,62 @@ CreateResource(D3D10DDI_HDEVICE hDevice, // IN sizeof *pResource->transfers); if (pCreateResource->pInitialDataUP) { - for (UINT SubResource = 0; SubResource < pResource->NumSubResources; ++SubResource) { + if (pResource->buffer) { + assert(pResource->NumSubResources == 1); const D3D10_DDIARG_SUBRESOURCE_UP* pInitialDataUP = - &pCreateResource->pInitialDataUP[SubResource]; + &pCreateResource->pInitialDataUP[0]; unsigned level; struct pipe_box box; - subResourceBox(pResource->resource, SubResource, &level, &box); + subResourceBox(pResource->resource, 0, &level, &box); struct pipe_transfer *transfer; void *map; - map = pipe->transfer_map(pipe, - pResource->resource, - level, - PIPE_MAP_WRITE | - PIPE_MAP_UNSYNCHRONIZED, - &box, - &transfer); + map = pipe->buffer_map(pipe, + pResource->resource, + level, + PIPE_MAP_WRITE | + PIPE_MAP_UNSYNCHRONIZED, + &box, + &transfer); assert(map); if (map) { - for (int z = 0; z < box.depth; ++z) { - ubyte *dst = (ubyte*)map + z*transfer->layer_stride; - const ubyte *src = (const ubyte*)pInitialDataUP->pSysMem + z*pInitialDataUP->SysMemSlicePitch; - util_copy_rect(dst, - templat.format, - transfer->stride, - 0, 0, box.width, box.height, - src, - pInitialDataUP->SysMemPitch, - 0, 0); + memcpy(map, pInitialDataUP->pSysMem, box.width); + pipe_buffer_unmap(pipe, transfer); + } + } else { + for (UINT SubResource = 0; SubResource < pResource->NumSubResources; ++SubResource) { + const D3D10_DDIARG_SUBRESOURCE_UP* pInitialDataUP = + &pCreateResource->pInitialDataUP[SubResource]; + + unsigned level; + struct pipe_box box; + subResourceBox(pResource->resource, SubResource, &level, &box); + + struct pipe_transfer *transfer; + void *map; + map = pipe->texture_map(pipe, + pResource->resource, + level, + PIPE_MAP_WRITE | + PIPE_MAP_UNSYNCHRONIZED, + &box, + &transfer); + assert(map); + if (map) { + for (int z = 0; z < box.depth; ++z) { + ubyte *dst = (ubyte*)map + z*transfer->layer_stride; + const ubyte *src = (const ubyte*)pInitialDataUP->pSysMem + z*pInitialDataUP->SysMemSlicePitch; + util_copy_rect(dst, + templat.format, + transfer->stride, + 0, 0, box.width, box.height, + src, + pInitialDataUP->SysMemPitch, + 0, 0); + } + pipe_texture_unmap(pipe, transfer); } - pipe_transfer_unmap(pipe, transfer); } } } @@ -423,7 +449,11 @@ DestroyResource(D3D10DDI_HDEVICE hDevice, // IN for (UINT SubResource = 0; SubResource < pResource->NumSubResources; ++SubResource) { if (pResource->transfers[SubResource]) { - pipe_transfer_unmap(pipe, pResource->transfers[SubResource]); + if (pResource->buffer) { + pipe_buffer_unmap(pipe, pResource->transfers[SubResource]); + } else { + pipe_texture_unmap(pipe, pResource->transfers[SubResource]); + } pResource->transfers[SubResource] = NULL; } } @@ -493,12 +523,21 @@ ResourceMap(D3D10DDI_HDEVICE hDevice, // IN assert(!pResource->transfers[SubResource]); void *map; - map = pipe->transfer_map(pipe, - resource, - level, - usage, - &box, - &pResource->transfers[SubResource]); + if (pResource->buffer) { + map = pipe->buffer_map(pipe, + resource, + level, + usage, + &box, + &pResource->transfers[SubResource]); + } else { + map = pipe->texture_map(pipe, + resource, + level, + usage, + &box, + &pResource->transfers[SubResource]); + } if (!map) { DebugPrintf("%s: failed to map resource\n", __FUNCTION__); SetError(hDevice, E_FAIL); @@ -534,7 +573,11 @@ ResourceUnmap(D3D10DDI_HDEVICE hDevice, // IN assert(SubResource < pResource->NumSubResources); if (pResource->transfers[SubResource]) { - pipe_transfer_unmap(pipe, pResource->transfers[SubResource]); + if (pResource->buffer) { + pipe_buffer_unmap(pipe, pResource->transfers[SubResource]); + } else { + pipe_texture_unmap(pipe, pResource->transfers[SubResource]); + } pResource->transfers[SubResource] = NULL; } } @@ -834,7 +877,8 @@ ResourceUpdateSubResourceUP(D3D10DDI_HDEVICE hDevice, // IN } struct pipe_context *pipe = pDevice->pipe; - struct pipe_resource *dst_resource = CastPipeResource(hDstResource); + Resource *pDstResource = CastResource(hDstResource); + struct pipe_resource *dst_resource = pDstResource->resource; unsigned level; struct pipe_box box; @@ -855,12 +899,21 @@ ResourceUpdateSubResourceUP(D3D10DDI_HDEVICE hDevice, // IN struct pipe_transfer *transfer; void *map; - map = pipe->transfer_map(pipe, - dst_resource, - level, - PIPE_MAP_WRITE | PIPE_MAP_DISCARD_RANGE, - &box, - &transfer); + if (pDstResource->buffer) { + map = pipe->buffer_map(pipe, + dst_resource, + level, + PIPE_MAP_WRITE | PIPE_MAP_DISCARD_RANGE, + &box, + &transfer); + } else { + map = pipe->texture_map(pipe, + dst_resource, + level, + PIPE_MAP_WRITE | PIPE_MAP_DISCARD_RANGE, + &box, + &transfer); + } assert(map); if (map) { for (int z = 0; z < box.depth; ++z) { @@ -874,7 +927,11 @@ ResourceUpdateSubResourceUP(D3D10DDI_HDEVICE hDevice, // IN RowPitch, 0, 0); } - pipe_transfer_unmap(pipe, transfer); + if (pDstResource->buffer) { + pipe_buffer_unmap(pipe, transfer); + } else { + pipe_texture_unmap(pipe, transfer); + } } } diff --git a/src/gallium/frontends/d3d10umd/ShaderParse.c b/src/gallium/frontends/d3d10umd/ShaderParse.c index e4b6b88aa72909b6dc02c23dd13e442f9d3f4361..1995d381880d172ac49fe0d4461d439f35cf32b5 100644 --- a/src/gallium/frontends/d3d10umd/ShaderParse.c +++ b/src/gallium/frontends/d3d10umd/ShaderParse.c @@ -392,7 +392,7 @@ Shader_parse_opcode(struct Shader_parser *parser, if (opcode_is_extended) { /* NOTE: DECODE_IS_D3D10_SB_OPCODE_DOUBLE_EXTENDED is broken. */ - assert(!((*curr & D3D10_SB_OPCODE_DOUBLE_EXTENDED_MASK) >> D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT)); + assert(!((*curr & D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK) >> D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT)); switch (DECODE_D3D10_SB_EXTENDED_OPCODE_TYPE(*curr)) { case D3D10_SB_EXTENDED_OPCODE_EMPTY: diff --git a/src/gallium/frontends/d3d10umd/ShaderParse.h b/src/gallium/frontends/d3d10umd/ShaderParse.h index 5e8fba044ab5faf92f78d4f2bb75ec110752adb8..df95536f2b53eef900961f221100d4f2821a0f5d 100644 --- a/src/gallium/frontends/d3d10umd/ShaderParse.h +++ b/src/gallium/frontends/d3d10umd/ShaderParse.h @@ -35,9 +35,6 @@ #include "DriverIncludes.h" -//#include "winddk/winddk_compat.h" -#include "winddk/d3d10tokenizedprogramformat.hpp" - #ifdef __cplusplus extern "C" { #endif diff --git a/src/gallium/frontends/d3d10umd/State.h b/src/gallium/frontends/d3d10umd/State.h index 5cb865ce69573a16e24e14df88e53a0e48c80130..3e45cb797435b40da0a4a1f5476fab2aecca08fd 100644 --- a/src/gallium/frontends/d3d10umd/State.h +++ b/src/gallium/frontends/d3d10umd/State.h @@ -150,6 +150,7 @@ struct Resource DXGI_FORMAT Format; UINT MipLevels; UINT NumSubResources; + bool buffer; struct pipe_resource *resource; struct pipe_transfer **transfers; struct pipe_stream_output_target *so_target; diff --git a/src/gallium/frontends/d3d10umd/meson.build b/src/gallium/frontends/d3d10umd/meson.build index 90774d9217d3ab5f4267974ae9018f55ab709f42..7141c8da17f7500b2d6e8e20faba9b5c70ab01d8 100644 --- a/src/gallium/frontends/d3d10umd/meson.build +++ b/src/gallium/frontends/d3d10umd/meson.build @@ -14,7 +14,7 @@ libd3d10umd = static_library( 'Debug.cpp', 'Device.cpp', 'Draw.cpp', - 'Dxgi.cpp', + 'DxgiFns.cpp', 'Format.cpp', 'InputAssembly.cpp', 'OutputMerger.cpp',