New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
void gs_texture_2d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd)
|
||||
{
|
||||
uint32_t rowSizeBytes = width * gs_get_format_bpp(format);
|
||||
uint32_t texSizeBytes = height * rowSizeBytes / 8;
|
||||
size_t textures = type == GS_TEXTURE_2D ? 1 : 6;
|
||||
uint32_t rowSizeBytes = width * gs_get_format_bpp(format);
|
||||
uint32_t texSizeBytes = height * rowSizeBytes / 8;
|
||||
size_t textures = type == GS_TEXTURE_2D ? 1 : 6;
|
||||
uint32_t actual_levels = levels;
|
||||
size_t curTex = 0;
|
||||
size_t curTex = 0;
|
||||
|
||||
if (!actual_levels)
|
||||
actual_levels = gs_get_total_levels(width, height);
|
||||
|
|
@ -37,8 +37,8 @@ void gs_texture_2d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd)
|
|||
|
||||
for (uint32_t j = 0; j < actual_levels; j++) {
|
||||
D3D11_SUBRESOURCE_DATA newSRD;
|
||||
newSRD.pSysMem = data[curTex++].data();
|
||||
newSRD.SysMemPitch = newRowSize;
|
||||
newSRD.pSysMem = data[curTex++].data();
|
||||
newSRD.SysMemPitch = newRowSize;
|
||||
newSRD.SysMemSlicePitch = newTexSize;
|
||||
srd.push_back(newSRD);
|
||||
|
||||
|
|
@ -78,8 +78,10 @@ void gs_texture_2d::GetSharedHandle(IDXGIResource *dxgi_res)
|
|||
|
||||
hr = dxgi_res->GetSharedHandle(&handle);
|
||||
if (FAILED(hr)) {
|
||||
blog(LOG_WARNING, "GetSharedHandle: Failed to "
|
||||
"get shared handle: %08lX", hr);
|
||||
blog(LOG_WARNING,
|
||||
"GetSharedHandle: Failed to "
|
||||
"get shared handle: %08lX",
|
||||
hr);
|
||||
} else {
|
||||
sharedHandle = (uint32_t)(uintptr_t)handle;
|
||||
}
|
||||
|
|
@ -90,16 +92,15 @@ void gs_texture_2d::InitTexture(const uint8_t **data)
|
|||
HRESULT hr;
|
||||
|
||||
memset(&td, 0, sizeof(td));
|
||||
td.Width = width;
|
||||
td.Height = height;
|
||||
td.MipLevels = genMipmaps ? 0 : levels;
|
||||
td.ArraySize = type == GS_TEXTURE_CUBE ? 6 : 1;
|
||||
td.Format = nv12 ? DXGI_FORMAT_NV12 : dxgiFormat;
|
||||
td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
td.Width = width;
|
||||
td.Height = height;
|
||||
td.MipLevels = genMipmaps ? 0 : levels;
|
||||
td.ArraySize = type == GS_TEXTURE_CUBE ? 6 : 1;
|
||||
td.Format = nv12 ? DXGI_FORMAT_NV12 : dxgiFormat;
|
||||
td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
td.SampleDesc.Count = 1;
|
||||
td.CPUAccessFlags = isDynamic ? D3D11_CPU_ACCESS_WRITE : 0;
|
||||
td.Usage = isDynamic ? D3D11_USAGE_DYNAMIC :
|
||||
D3D11_USAGE_DEFAULT;
|
||||
td.CPUAccessFlags = isDynamic ? D3D11_CPU_ACCESS_WRITE : 0;
|
||||
td.Usage = isDynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT;
|
||||
|
||||
if (type == GS_TEXTURE_CUBE)
|
||||
td.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
|
||||
|
|
@ -121,13 +122,13 @@ void gs_texture_2d::InitTexture(const uint8_t **data)
|
|||
}
|
||||
|
||||
hr = device->device->CreateTexture2D(&td, data ? srd.data() : NULL,
|
||||
texture.Assign());
|
||||
texture.Assign());
|
||||
if (FAILED(hr))
|
||||
throw HRError("Failed to create 2D texture", hr);
|
||||
|
||||
if (isGDICompatible) {
|
||||
hr = texture->QueryInterface(__uuidof(IDXGISurface1),
|
||||
(void**)gdiSurface.Assign());
|
||||
(void **)gdiSurface.Assign());
|
||||
if (FAILED(hr))
|
||||
throw HRError("Failed to create GDI surface", hr);
|
||||
}
|
||||
|
|
@ -138,22 +139,24 @@ void gs_texture_2d::InitTexture(const uint8_t **data)
|
|||
texture->SetEvictionPriority(DXGI_RESOURCE_PRIORITY_MAXIMUM);
|
||||
|
||||
hr = texture->QueryInterface(__uuidof(IDXGIResource),
|
||||
(void**)&dxgi_res);
|
||||
(void **)&dxgi_res);
|
||||
if (FAILED(hr)) {
|
||||
blog(LOG_WARNING, "InitTexture: Failed to query "
|
||||
"interface: %08lX", hr);
|
||||
blog(LOG_WARNING,
|
||||
"InitTexture: Failed to query "
|
||||
"interface: %08lX",
|
||||
hr);
|
||||
} else {
|
||||
GetSharedHandle(dxgi_res);
|
||||
|
||||
if (flags & GS_SHARED_KM_TEX) {
|
||||
ComPtr<IDXGIKeyedMutex> km;
|
||||
hr = texture->QueryInterface(
|
||||
__uuidof(IDXGIKeyedMutex),
|
||||
(void**)&km);
|
||||
__uuidof(IDXGIKeyedMutex),
|
||||
(void **)&km);
|
||||
if (FAILED(hr)) {
|
||||
throw HRError("Failed to query "
|
||||
"IDXGIKeyedMutex",
|
||||
hr);
|
||||
"IDXGIKeyedMutex",
|
||||
hr);
|
||||
}
|
||||
|
||||
km->AcquireSync(0, INFINITE);
|
||||
|
|
@ -181,7 +184,7 @@ void gs_texture_2d::InitResourceView()
|
|||
}
|
||||
|
||||
hr = device->device->CreateShaderResourceView(texture, &resourceDesc,
|
||||
shaderRes.Assign());
|
||||
shaderRes.Assign());
|
||||
if (FAILED(hr))
|
||||
throw HRError("Failed to create resource view", hr);
|
||||
}
|
||||
|
|
@ -193,27 +196,28 @@ void gs_texture_2d::InitRenderTargets()
|
|||
D3D11_RENDER_TARGET_VIEW_DESC rtv;
|
||||
rtv.Format = dxgiFormat;
|
||||
rtv.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
rtv.Texture2D.MipSlice = 0;
|
||||
rtv.Texture2D.MipSlice = 0;
|
||||
|
||||
hr = device->device->CreateRenderTargetView(texture, &rtv,
|
||||
renderTarget[0].Assign());
|
||||
hr = device->device->CreateRenderTargetView(
|
||||
texture, &rtv, renderTarget[0].Assign());
|
||||
if (FAILED(hr))
|
||||
throw HRError("Failed to create render target view",
|
||||
hr);
|
||||
hr);
|
||||
} else {
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtv;
|
||||
rtv.Format = dxgiFormat;
|
||||
rtv.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
|
||||
rtv.Texture2DArray.MipSlice = 0;
|
||||
rtv.Texture2DArray.MipSlice = 0;
|
||||
rtv.Texture2DArray.ArraySize = 1;
|
||||
|
||||
for (UINT i = 0; i < 6; i++) {
|
||||
rtv.Texture2DArray.FirstArraySlice = i;
|
||||
hr = device->device->CreateRenderTargetView(texture,
|
||||
&rtv, renderTarget[i].Assign());
|
||||
hr = device->device->CreateRenderTargetView(
|
||||
texture, &rtv, renderTarget[i].Assign());
|
||||
if (FAILED(hr))
|
||||
throw HRError("Failed to create cube render "
|
||||
"target view", hr);
|
||||
"target view",
|
||||
hr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -221,22 +225,22 @@ void gs_texture_2d::InitRenderTargets()
|
|||
#define SHARED_FLAGS (GS_SHARED_TEX | GS_SHARED_KM_TEX)
|
||||
|
||||
gs_texture_2d::gs_texture_2d(gs_device_t *device, uint32_t width,
|
||||
uint32_t height, gs_color_format colorFormat, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags_, gs_texture_type type,
|
||||
bool gdiCompatible, bool nv12_)
|
||||
: gs_texture (device, gs_type::gs_texture_2d, type, levels,
|
||||
colorFormat),
|
||||
width (width),
|
||||
height (height),
|
||||
flags (flags_),
|
||||
dxgiFormat (ConvertGSTextureFormat(format)),
|
||||
isRenderTarget ((flags_ & GS_RENDER_TARGET) != 0),
|
||||
isGDICompatible (gdiCompatible),
|
||||
isDynamic ((flags_ & GS_DYNAMIC) != 0),
|
||||
isShared ((flags_ & SHARED_FLAGS) != 0),
|
||||
genMipmaps ((flags_ & GS_BUILD_MIPMAPS) != 0),
|
||||
sharedHandle (GS_INVALID_HANDLE),
|
||||
nv12 (nv12_)
|
||||
uint32_t height, gs_color_format colorFormat,
|
||||
uint32_t levels, const uint8_t **data,
|
||||
uint32_t flags_, gs_texture_type type,
|
||||
bool gdiCompatible, bool nv12_)
|
||||
: gs_texture(device, gs_type::gs_texture_2d, type, levels, colorFormat),
|
||||
width(width),
|
||||
height(height),
|
||||
flags(flags_),
|
||||
dxgiFormat(ConvertGSTextureFormat(format)),
|
||||
isRenderTarget((flags_ & GS_RENDER_TARGET) != 0),
|
||||
isGDICompatible(gdiCompatible),
|
||||
isDynamic((flags_ & GS_DYNAMIC) != 0),
|
||||
isShared((flags_ & SHARED_FLAGS) != 0),
|
||||
genMipmaps((flags_ & GS_BUILD_MIPMAPS) != 0),
|
||||
sharedHandle(GS_INVALID_HANDLE),
|
||||
nv12(nv12_)
|
||||
{
|
||||
InitTexture(data);
|
||||
InitResourceView();
|
||||
|
|
@ -246,25 +250,25 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, uint32_t width,
|
|||
}
|
||||
|
||||
gs_texture_2d::gs_texture_2d(gs_device_t *device, ID3D11Texture2D *nv12tex,
|
||||
uint32_t flags_)
|
||||
: gs_texture (device, gs_type::gs_texture_2d, GS_TEXTURE_2D),
|
||||
isRenderTarget ((flags_ & GS_RENDER_TARGET) != 0),
|
||||
isDynamic ((flags_ & GS_DYNAMIC) != 0),
|
||||
isShared ((flags_ & SHARED_FLAGS) != 0),
|
||||
genMipmaps ((flags_ & GS_BUILD_MIPMAPS) != 0),
|
||||
nv12 (true)
|
||||
uint32_t flags_)
|
||||
: gs_texture(device, gs_type::gs_texture_2d, GS_TEXTURE_2D),
|
||||
isRenderTarget((flags_ & GS_RENDER_TARGET) != 0),
|
||||
isDynamic((flags_ & GS_DYNAMIC) != 0),
|
||||
isShared((flags_ & SHARED_FLAGS) != 0),
|
||||
genMipmaps((flags_ & GS_BUILD_MIPMAPS) != 0),
|
||||
nv12(true),
|
||||
texture(nv12tex)
|
||||
{
|
||||
texture = nv12tex;
|
||||
texture->GetDesc(&td);
|
||||
|
||||
this->type = GS_TEXTURE_2D;
|
||||
this->format = GS_R8G8;
|
||||
this->flags = flags_;
|
||||
this->levels = 1;
|
||||
this->device = device;
|
||||
this->chroma = true;
|
||||
this->width = td.Width / 2;
|
||||
this->height = td.Height / 2;
|
||||
this->type = GS_TEXTURE_2D;
|
||||
this->format = GS_R8G8;
|
||||
this->flags = flags_;
|
||||
this->levels = 1;
|
||||
this->device = device;
|
||||
this->chroma = true;
|
||||
this->width = td.Width / 2;
|
||||
this->height = td.Height / 2;
|
||||
this->dxgiFormat = DXGI_FORMAT_R8G8_UNORM;
|
||||
|
||||
InitResourceView();
|
||||
|
|
@ -273,35 +277,35 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, ID3D11Texture2D *nv12tex,
|
|||
}
|
||||
|
||||
gs_texture_2d::gs_texture_2d(gs_device_t *device, uint32_t handle)
|
||||
: gs_texture (device, gs_type::gs_texture_2d,
|
||||
GS_TEXTURE_2D),
|
||||
isShared (true),
|
||||
sharedHandle (handle)
|
||||
: gs_texture(device, gs_type::gs_texture_2d, GS_TEXTURE_2D),
|
||||
isShared(true),
|
||||
sharedHandle(handle)
|
||||
{
|
||||
HRESULT hr;
|
||||
hr = device->device->OpenSharedResource((HANDLE)(uintptr_t)handle,
|
||||
__uuidof(ID3D11Texture2D), (void**)texture.Assign());
|
||||
__uuidof(ID3D11Texture2D),
|
||||
(void **)texture.Assign());
|
||||
if (FAILED(hr))
|
||||
throw HRError("Failed to open shared 2D texture", hr);
|
||||
|
||||
texture->GetDesc(&td);
|
||||
|
||||
this->type = GS_TEXTURE_2D;
|
||||
this->format = ConvertDXGITextureFormat(td.Format);
|
||||
this->levels = 1;
|
||||
this->device = device;
|
||||
this->type = GS_TEXTURE_2D;
|
||||
this->format = ConvertDXGITextureFormat(td.Format);
|
||||
this->levels = 1;
|
||||
this->device = device;
|
||||
|
||||
this->width = td.Width;
|
||||
this->height = td.Height;
|
||||
this->width = td.Width;
|
||||
this->height = td.Height;
|
||||
this->dxgiFormat = td.Format;
|
||||
|
||||
memset(&resourceDesc, 0, sizeof(resourceDesc));
|
||||
resourceDesc.Format = td.Format;
|
||||
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
resourceDesc.Format = td.Format;
|
||||
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
resourceDesc.Texture2D.MipLevels = 1;
|
||||
|
||||
hr = device->device->CreateShaderResourceView(texture, &resourceDesc,
|
||||
shaderRes.Assign());
|
||||
shaderRes.Assign());
|
||||
if (FAILED(hr))
|
||||
throw HRError("Failed to create shader resource view", hr);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue