New upstream version 26.1.0+dfsg1

This commit is contained in:
Sebastian Ramacher 2020-12-22 18:32:50 +01:00
parent 040dcc3fc2
commit 013818c4af
594 changed files with 19576 additions and 4478 deletions

View file

@ -2670,6 +2670,23 @@ extern "C" EXPORT uint32_t device_texture_get_shared_handle(gs_texture_t *tex)
return tex2d->isShared ? tex2d->sharedHandle : GS_INVALID_HANDLE;
}
extern "C" EXPORT gs_texture_t *device_texture_wrap_obj(gs_device_t *device,
void *obj)
{
gs_texture *texture = nullptr;
try {
texture = new gs_texture_2d(device, (ID3D11Texture2D *)obj);
} catch (const HRError &error) {
blog(LOG_ERROR, "gs_texture_wrap_obj (D3D11): %s (%08lX)",
error.str, error.hr);
LogD3D11ErrorDetails(error, device);
} catch (const char *error) {
blog(LOG_ERROR, "gs_texture_wrap_obj (D3D11): %s", error);
}
return texture;
}
int device_texture_acquire_sync(gs_texture_t *tex, uint64_t key, uint32_t ms)
{
gs_texture_2d *tex2d = reinterpret_cast<gs_texture_2d *>(tex);

View file

@ -490,6 +490,7 @@ struct gs_texture_2d : gs_texture {
gs_texture_2d(gs_device_t *device, ID3D11Texture2D *nv12,
uint32_t flags);
gs_texture_2d(gs_device_t *device, uint32_t handle);
gs_texture_2d(gs_device_t *device, ID3D11Texture2D *obj);
};
struct gs_texture_3d : gs_texture {

View file

@ -311,3 +311,30 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, uint32_t handle)
if (FAILED(hr))
throw HRError("Failed to create shader resource view", hr);
}
gs_texture_2d::gs_texture_2d(gs_device_t *device, ID3D11Texture2D *obj)
: gs_texture(device, gs_type::gs_texture_2d, GS_TEXTURE_2D)
{
texture = obj;
texture->GetDesc(&td);
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->dxgiFormat = td.Format;
memset(&resourceDesc, 0, sizeof(resourceDesc));
resourceDesc.Format = td.Format;
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceDesc.Texture2D.MipLevels = 1;
HRESULT hr = device->device->CreateShaderResourceView(
texture, &resourceDesc, shaderRes.Assign());
if (FAILED(hr))
throw HRError("Failed to create shader resource view", hr);
}