Commit 66839438 by Nicolas Capens

Adapt D3D9 to Renderer changes.

Bug 22533227 Change-Id: Ib1b17bcace85bc6204589a48c65f60c94ffbe5cc Reviewed-on: https://swiftshader-review.googlesource.com/3732Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 2876e097
...@@ -42,6 +42,30 @@ namespace sw ...@@ -42,6 +42,30 @@ namespace sw
} }
template<class T> template<class T>
inline T max(T a, T b, T c)
{
return max(max(a, b), c);
}
template<class T>
inline T min(T a, T b, T c)
{
return min(min(a, b), c);
}
template<class T>
inline T max(T a, T b, T c, T d)
{
return max(max(a, b), max(c, d));
}
template<class T>
inline T min(T a, T b, T c, T d)
{
return min(min(a, b), min(c, d));
}
template<class T>
inline void swap(T &a, T &b) inline void swap(T &a, T &b)
{ {
T t = a; T t = a;
......
...@@ -203,7 +203,7 @@ ...@@ -203,7 +203,7 @@
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;DLL;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;DLL;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
...@@ -288,7 +288,7 @@ ...@@ -288,7 +288,7 @@
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;DLL;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\;..\Main;..\Renderer;..\Shader;..\Common;..\SwiftAsm;..\libjpeg;..\SwiftShader;..\D3D9;..\Reactor;..\LLVM\include;..\LLVM\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;DLL;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;D3D9DLL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
......
...@@ -256,13 +256,13 @@ namespace D3D9 ...@@ -256,13 +256,13 @@ namespace D3D9
bool lightsDirty; bool lightsDirty;
bool pixelShaderDirty; bool pixelShaderDirty;
int pixelShaderConstantsBDirty; unsigned int pixelShaderConstantsBDirty;
int pixelShaderConstantsFDirty; unsigned int pixelShaderConstantsFDirty;
int pixelShaderConstantsIDirty; unsigned int pixelShaderConstantsIDirty;
bool vertexShaderDirty; bool vertexShaderDirty;
int vertexShaderConstantsBDirty; unsigned int vertexShaderConstantsBDirty;
int vertexShaderConstantsFDirty; unsigned int vertexShaderConstantsFDirty;
int vertexShaderConstantsIDirty; unsigned int vertexShaderConstantsIDirty;
float pixelShaderConstantF[224][4]; float pixelShaderConstantF[224][4];
int pixelShaderConstantI[16][4]; int pixelShaderConstantI[16][4];
......
...@@ -180,11 +180,11 @@ namespace D3D9 ...@@ -180,11 +180,11 @@ namespace D3D9
indexBuffer->destruct(); indexBuffer->destruct();
indexBuffer = new sw::Resource(length + 16); indexBuffer = new sw::Resource(length + 16);
buffer = (void*)indexBuffer->getBuffer(); buffer = (void*)indexBuffer->data();
} }
else if(flags & D3DLOCK_NOOVERWRITE/* && usage & D3DUSAGE_DYNAMIC*/) else if(flags & D3DLOCK_NOOVERWRITE/* && usage & D3DUSAGE_DYNAMIC*/)
{ {
buffer = (void*)indexBuffer->getBuffer(); buffer = (void*)indexBuffer->data();
} }
else else
{ {
......
...@@ -86,7 +86,7 @@ namespace D3D9 ...@@ -86,7 +86,7 @@ namespace D3D9
return INVALIDCALL(); return INVALIDCALL();
} }
pixelShader.getFunction(data, size); UNIMPLEMENTED();
return D3D_OK; return D3D_OK;
} }
......
...@@ -382,8 +382,8 @@ namespace D3D9 ...@@ -382,8 +382,8 @@ namespace D3D9
case D3DFMT_D24S8: return sw::FORMAT_D24S8; case D3DFMT_D24S8: return sw::FORMAT_D24S8;
case D3DFMT_D24FS8: return sw::FORMAT_D24FS8; case D3DFMT_D24FS8: return sw::FORMAT_D24FS8;
case D3DFMT_D32F_LOCKABLE: return sw::FORMAT_D32F_LOCKABLE; case D3DFMT_D32F_LOCKABLE: return sw::FORMAT_D32F_LOCKABLE;
case D3DFMT_DF24: return sw::FORMAT_DF24; case D3DFMT_DF24: return sw::FORMAT_DF24S8;
case D3DFMT_DF16: return sw::FORMAT_DF16; case D3DFMT_DF16: return sw::FORMAT_DF16S8;
case D3DFMT_INTZ: return sw::FORMAT_INTZ; case D3DFMT_INTZ: return sw::FORMAT_INTZ;
default: default:
ASSERT(false); ASSERT(false);
......
...@@ -147,7 +147,7 @@ namespace D3D9 ...@@ -147,7 +147,7 @@ namespace D3D9
HWND window = destWindowOverride ? destWindowOverride : presentParameters.hDeviceWindow; HWND window = destWindowOverride ? destWindowOverride : presentParameters.hDeviceWindow;
void *source = backBuffer[0]->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC); // FIXME: External void *source = backBuffer[0]->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC); // FIXME: External
bool HDR = backBuffer[0]->getInternalFormat() == sw::FORMAT_A16B16G16R16; sw::Format format = backBuffer[0]->getInternalFormat();
POINT point; POINT point;
GetCursorPos(&point); GetCursorPos(&point);
...@@ -157,30 +157,30 @@ namespace D3D9 ...@@ -157,30 +157,30 @@ namespace D3D9
if(!sourceRect && !destRect) // FIXME: More cases? if(!sourceRect && !destRect) // FIXME: More cases?
{ {
frameBuffer->flip(window, source, HDR); frameBuffer->flip(window, source, format);
} }
else // FIXME: Check for SWAPEFFECT_COPY else // FIXME: Check for SWAPEFFECT_COPY
{ {
sw::Rect sRect = {0}; sw::Rect sRect(0, 0, 0, 0);
sw::Rect dRect = {0}; sw::Rect dRect(0, 0, 0, 0);
if(sourceRect) if(sourceRect)
{ {
sRect.left = sourceRect->left; sRect.x0 = sourceRect->left;
sRect.top = sourceRect->top; sRect.y0 = sourceRect->top;
sRect.right = sourceRect->right; sRect.x1 = sourceRect->right;
sRect.bottom = sourceRect->bottom; sRect.y1 = sourceRect->bottom;
} }
if(destRect) if(destRect)
{ {
dRect.left = destRect->left; dRect.x0 = destRect->left;
dRect.top = destRect->top; dRect.y0 = destRect->top;
dRect.right = destRect->right; dRect.x1 = destRect->right;
dRect.bottom = destRect->bottom; dRect.y1 = destRect->bottom;
} }
frameBuffer->blit(window, source, sourceRect ? &sRect : 0, destRect ? &dRect : 0, HDR); frameBuffer->blit(window, source, sourceRect ? &sRect : 0, destRect ? &dRect : 0, format);
} }
backBuffer[0]->unlockInternal(); // FIXME: External backBuffer[0]->unlockInternal(); // FIXME: External
...@@ -343,20 +343,9 @@ namespace D3D9 ...@@ -343,20 +343,9 @@ namespace D3D9
presentParameters->BackBufferHeight = rectangle.bottom - rectangle.top; presentParameters->BackBufferHeight = rectangle.bottom - rectangle.top;
} }
lockable = presentParameters->Flags & D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; frameBuffer = createFrameBufferWin(windowHandle, presentParameters->BackBufferWidth, presentParameters->BackBufferHeight, presentParameters->Windowed == FALSE, true);
sw::Configurator ini("SwiftShader.ini");
int api = ini.getInteger("Testing", "FrameBufferAPI", 1);
if(api == 0) lockable = presentParameters->Flags & D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
{
frameBuffer = new sw::FrameBufferDD(windowHandle, presentParameters->BackBufferWidth, presentParameters->BackBufferHeight, presentParameters->Windowed == FALSE);
}
else if(api == 1)
{
frameBuffer = new sw::FrameBufferGDI(windowHandle, presentParameters->BackBufferWidth, presentParameters->BackBufferHeight, presentParameters->Windowed == FALSE);
}
else ASSERT(false);
backBuffer[0] = 0; backBuffer[0] = 0;
backBuffer[1] = 0; backBuffer[1] = 0;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "Direct3DSurface9.hpp" #include "Direct3DSurface9.hpp"
#include "FrameBuffer.hpp" #include "FrameBufferWin.hpp"
#include <d3d9.h> #include <d3d9.h>
...@@ -63,7 +63,7 @@ namespace D3D9 ...@@ -63,7 +63,7 @@ namespace D3D9
bool lockable; bool lockable;
sw::FrameBuffer *frameBuffer; sw::FrameBufferWin *frameBuffer;
public: // FIXME public: // FIXME
Direct3DSurface9 *backBuffer[3]; Direct3DSurface9 *backBuffer[3];
......
...@@ -199,11 +199,11 @@ namespace D3D9 ...@@ -199,11 +199,11 @@ namespace D3D9
vertexBuffer->destruct(); vertexBuffer->destruct();
vertexBuffer = new sw::Resource(length + 192 + 1024); // NOTE: Applications can 'overshoot' while writing vertices vertexBuffer = new sw::Resource(length + 192 + 1024); // NOTE: Applications can 'overshoot' while writing vertices
buffer = (void*)vertexBuffer->getBuffer(); buffer = (void*)vertexBuffer->data();
} }
else if(flags & D3DLOCK_NOOVERWRITE/* && usage & D3DUSAGE_DYNAMIC*/) else if(flags & D3DLOCK_NOOVERWRITE/* && usage & D3DUSAGE_DYNAMIC*/)
{ {
buffer = (void*)vertexBuffer->getBuffer(); buffer = (void*)vertexBuffer->data();
} }
else else
{ {
......
...@@ -86,7 +86,7 @@ namespace D3D9 ...@@ -86,7 +86,7 @@ namespace D3D9
return INVALIDCALL(); return INVALIDCALL();
} }
vertexShader.getFunction(data, size); UNIMPLEMENTED();
return D3D_OK; return D3D_OK;
} }
......
...@@ -190,13 +190,13 @@ namespace D3D9 ...@@ -190,13 +190,13 @@ namespace D3D9
source->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC); source->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);
dest->lockInternal(0, 0, 0, sw::LOCK_DISCARD, sw::PUBLIC); dest->lockInternal(0, 0, 0, sw::LOCK_DISCARD, sw::PUBLIC);
int sWidth = source->getInternalWidth(); int sWidth = source->getWidth();
int sHeight = source->getInternalHeight(); int sHeight = source->getHeight();
int sDepth = source->getInternalDepth(); int sDepth = source->getDepth();
int dWidth = dest->getInternalWidth(); int dWidth = dest->getWidth();
int dHeight = dest->getInternalHeight(); int dHeight = dest->getHeight();
int dDepth = dest->getInternalDepth(); int dDepth = dest->getDepth();
D3DTEXTUREFILTERTYPE filter = GetAutoGenFilterType(); D3DTEXTUREFILTERTYPE filter = GetAutoGenFilterType();
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
DEFINE_GUID(IID_SwiftShaderPrivateV1, 0x761954E6, 0xC357, 0x426d, 0xA6, 0x90, 0x00, 0x50, 0x56, 0xC0, 0x00, 0x08); DEFINE_GUID(IID_SwiftShaderPrivateV1, 0x761954E6, 0xC357, 0x426d, 0xA6, 0x90, 0x00, 0x50, 0x56, 0xC0, 0x00, 0x08);
extern SWFILTER maximumFilterQuality; //extern SWFILTER maximumFilterQuality;
extern SWFILTER maximumMipmapQuality; //extern SWFILTER maximumMipmapQuality;
extern SWPERSPECTIVE perspectiveQuality; //extern SWPERSPECTIVE perspectiveQuality;
extern bool disableServer; extern bool disableServer;
namespace D3D9 namespace D3D9
...@@ -85,13 +85,13 @@ namespace D3D9 ...@@ -85,13 +85,13 @@ namespace D3D9
switch(setting) switch(setting)
{ {
case SWS_MAXIMUMFILTERQUALITY: case SWS_MAXIMUMFILTERQUALITY:
maximumFilterQuality = (SWFILTER)value; // maximumFilterQuality = (SWFILTER)value;
break; break;
case SWS_MAXIMUMMIPMAPQUALITY: case SWS_MAXIMUMMIPMAPQUALITY:
maximumMipmapQuality = (SWFILTER)value; // maximumMipmapQuality = (SWFILTER)value;
break; break;
case SWS_PERSPECTIVEQUALITY: case SWS_PERSPECTIVEQUALITY:
perspectiveQuality = (SWPERSPECTIVE)value; // perspectiveQuality = (SWPERSPECTIVE)value;
break; break;
case SWS_DISABLESERVER: case SWS_DISABLESERVER:
disableServer = (value != FALSE); disableServer = (value != FALSE);
......
...@@ -54,4 +54,6 @@ namespace sw ...@@ -54,4 +54,6 @@ namespace sw
}; };
} }
sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin);
#endif // sw_FrameBufferWin_hpp #endif // sw_FrameBufferWin_hpp
...@@ -72,6 +72,15 @@ namespace sw ...@@ -72,6 +72,15 @@ namespace sw
false // leadingVertexFirst false // leadingVertexFirst
}; };
static const Conventions Direct3D =
{
false, // halfIntegerCoordinates
false, // symmetricNormalizedDepth
false, // booleanFaceRegister
false, // fullPixelPositionRegister
true // leadingVertexFirst
};
struct Query struct Query
{ {
Query() Query()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment