mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
Merge pull request #1641 from vlj/rsx
Rsx: Use typed class for texture parameters
This commit is contained in:
commit
427270884c
16 changed files with 369 additions and 221 deletions
|
@ -333,7 +333,7 @@ public:
|
|||
auto& vmfprog = vm::ps3::_ref<CgBinaryFragmentProgram>(ptr + vmprog.program);
|
||||
u32 size;
|
||||
u32 ctrl = (vmfprog.outputFromH0 ? 0 : 0x40) | (vmfprog.depthReplace ? 0xe : 0);
|
||||
std::vector<texture_dimension> td;
|
||||
std::vector<texture_dimension_extended> td;
|
||||
RSXFragmentProgram prog;
|
||||
prog.size = 0, prog.addr = vm::base(ptr + vmprog.ucode), prog.offset = 0, prog.ctrl = ctrl;
|
||||
GLFragmentDecompilerThread(m_glsl_shader, param_array, prog, size).Task();
|
||||
|
|
|
@ -130,16 +130,16 @@ std::string FragmentProgramDecompiler::AddTex()
|
|||
std::string sampler;
|
||||
switch (m_prog.get_texture_dimension(dst.tex_num))
|
||||
{
|
||||
case texture_dimension::texture_dimension_1d:
|
||||
case texture_dimension_extended::texture_dimension_1d:
|
||||
sampler = "sampler1D";
|
||||
break;
|
||||
case texture_dimension::texture_dimension_cubemap:
|
||||
case texture_dimension_extended::texture_dimension_cubemap:
|
||||
sampler = "samplerCube";
|
||||
break;
|
||||
case texture_dimension::texture_dimension_2d:
|
||||
case texture_dimension_extended::texture_dimension_2d:
|
||||
sampler = "sampler2D";
|
||||
break;
|
||||
case texture_dimension::texture_dimension_3d:
|
||||
case texture_dimension_extended::texture_dimension_3d:
|
||||
sampler = "sampler3D";
|
||||
break;
|
||||
}
|
||||
|
@ -442,16 +442,16 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
|
|||
case RSX_FP_OPCODE_TEX:
|
||||
switch (m_prog.get_texture_dimension(dst.tex_num))
|
||||
{
|
||||
case texture_dimension::texture_dimension_1d:
|
||||
case texture_dimension_extended::texture_dimension_1d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE1D));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_2d:
|
||||
case texture_dimension_extended::texture_dimension_2d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_cubemap:
|
||||
case texture_dimension_extended::texture_dimension_cubemap:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_3d:
|
||||
case texture_dimension_extended::texture_dimension_3d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE3D));
|
||||
return true;
|
||||
}
|
||||
|
@ -460,16 +460,16 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
|
|||
case RSX_FP_OPCODE_TXP:
|
||||
switch (m_prog.get_texture_dimension(dst.tex_num))
|
||||
{
|
||||
case texture_dimension::texture_dimension_1d:
|
||||
case texture_dimension_extended::texture_dimension_1d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE1D_PROJ));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_2d:
|
||||
case texture_dimension_extended::texture_dimension_2d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_cubemap:
|
||||
case texture_dimension_extended::texture_dimension_cubemap:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_PROJ));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_3d:
|
||||
case texture_dimension_extended::texture_dimension_3d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE3D_PROJ));
|
||||
return true;
|
||||
}
|
||||
|
@ -480,16 +480,16 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
|
|||
case RSX_FP_OPCODE_TXL:
|
||||
switch (m_prog.get_texture_dimension(dst.tex_num))
|
||||
{
|
||||
case texture_dimension::texture_dimension_1d:
|
||||
case texture_dimension_extended::texture_dimension_1d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE1D_LOD));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_2d:
|
||||
case texture_dimension_extended::texture_dimension_2d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_LOD));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_cubemap:
|
||||
case texture_dimension_extended::texture_dimension_cubemap:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_LOD));
|
||||
return true;
|
||||
case texture_dimension::texture_dimension_3d:
|
||||
case texture_dimension_extended::texture_dimension_3d:
|
||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE3D_LOD));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -124,18 +124,18 @@ std::vector<rsx_subresource_layout> get_subresources_layout(const rsx::texture &
|
|||
u16 depth;
|
||||
u8 layer;
|
||||
|
||||
if (texture.dimension() == 1)
|
||||
if (texture.dimension() == rsx::texture_dimension::dimension1d)
|
||||
{
|
||||
depth = 1;
|
||||
layer = 1;
|
||||
h = 1;
|
||||
}
|
||||
else if (texture.dimension() == 2)
|
||||
else if (texture.dimension() == rsx::texture_dimension::dimension2d)
|
||||
{
|
||||
depth = 1;
|
||||
layer = texture.cubemap() ? 6 : 1;
|
||||
}
|
||||
else if (texture.dimension() == 3)
|
||||
else if (texture.dimension() == rsx::texture_dimension::dimension3d)
|
||||
{
|
||||
depth = texture.depth();
|
||||
layer = 1;
|
||||
|
|
|
@ -172,89 +172,89 @@ DXGI_FORMAT get_texture_format(u8 format)
|
|||
throw EXCEPTION("Invalid or unsupported texture format (0x%x)", format);
|
||||
}
|
||||
|
||||
UINT get_texture_max_aniso(u8 aniso)
|
||||
UINT get_texture_max_aniso(rsx::texture_max_anisotropy aniso)
|
||||
{
|
||||
switch (aniso)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_1: return 1;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_2: return 2;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_4: return 4;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_6: return 6;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_8: return 8;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_10: return 10;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_12: return 12;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_16: return 16;
|
||||
case rsx::texture_max_anisotropy::x1: return 1;
|
||||
case rsx::texture_max_anisotropy::x2: return 2;
|
||||
case rsx::texture_max_anisotropy::x4: return 4;
|
||||
case rsx::texture_max_anisotropy::x6: return 6;
|
||||
case rsx::texture_max_anisotropy::x8: return 8;
|
||||
case rsx::texture_max_anisotropy::x10: return 10;
|
||||
case rsx::texture_max_anisotropy::x12: return 12;
|
||||
case rsx::texture_max_anisotropy::x16: return 16;
|
||||
}
|
||||
throw EXCEPTION("Invalid texture max aniso (0x%x)", aniso);
|
||||
}
|
||||
|
||||
D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(u8 wrap)
|
||||
D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(rsx::texture_wrap_mode wrap)
|
||||
{
|
||||
switch (wrap)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_WRAP: return D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
case CELL_GCM_TEXTURE_MIRROR: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
|
||||
case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
case CELL_GCM_TEXTURE_BORDER: return D3D12_TEXTURE_ADDRESS_MODE_BORDER;
|
||||
case CELL_GCM_TEXTURE_CLAMP: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE;
|
||||
case rsx::texture_wrap_mode::wrap: return D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
case rsx::texture_wrap_mode::mirror: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
|
||||
case rsx::texture_wrap_mode::clamp_to_edge: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
case rsx::texture_wrap_mode::border: return D3D12_TEXTURE_ADDRESS_MODE_BORDER;
|
||||
case rsx::texture_wrap_mode::clamp: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp_to_edge: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE;
|
||||
case rsx::texture_wrap_mode::mirror_once_border: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE;
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE;
|
||||
}
|
||||
throw EXCEPTION("Invalid texture wrap mode (0x%x)", wrap);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void get_min_filter(u8 min_filter, D3D12_FILTER_TYPE &min, D3D12_FILTER_TYPE &mip)
|
||||
void get_min_filter(rsx::texture_minify_filter min_filter, D3D12_FILTER_TYPE &min, D3D12_FILTER_TYPE &mip)
|
||||
{
|
||||
switch (min_filter)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_NEAREST:
|
||||
case rsx::texture_minify_filter::nearest:
|
||||
min = D3D12_FILTER_TYPE_POINT;
|
||||
mip = D3D12_FILTER_TYPE_POINT;
|
||||
return;
|
||||
case CELL_GCM_TEXTURE_LINEAR:
|
||||
case rsx::texture_minify_filter::linear:
|
||||
min = D3D12_FILTER_TYPE_LINEAR;
|
||||
mip = D3D12_FILTER_TYPE_POINT;
|
||||
return;
|
||||
case CELL_GCM_TEXTURE_NEAREST_NEAREST:
|
||||
case rsx::texture_minify_filter::nearest_nearest:
|
||||
min = D3D12_FILTER_TYPE_POINT;
|
||||
mip = D3D12_FILTER_TYPE_POINT;
|
||||
return;
|
||||
case CELL_GCM_TEXTURE_LINEAR_NEAREST:
|
||||
case rsx::texture_minify_filter::linear_nearest:
|
||||
min = D3D12_FILTER_TYPE_LINEAR;
|
||||
mip = D3D12_FILTER_TYPE_POINT;
|
||||
return;
|
||||
case CELL_GCM_TEXTURE_NEAREST_LINEAR:
|
||||
case rsx::texture_minify_filter::nearest_linear:
|
||||
min = D3D12_FILTER_TYPE_POINT;
|
||||
mip = D3D12_FILTER_TYPE_LINEAR;
|
||||
return;
|
||||
case CELL_GCM_TEXTURE_LINEAR_LINEAR:
|
||||
case rsx::texture_minify_filter::linear_linear:
|
||||
min = D3D12_FILTER_TYPE_LINEAR;
|
||||
mip = D3D12_FILTER_TYPE_LINEAR;
|
||||
return;
|
||||
case CELL_GCM_TEXTURE_CONVOLUTION_MIN:
|
||||
case rsx::texture_minify_filter::convolution_min:
|
||||
min = D3D12_FILTER_TYPE_LINEAR;
|
||||
mip = D3D12_FILTER_TYPE_POINT;
|
||||
return;
|
||||
}
|
||||
throw EXCEPTION("Invalid max filter (0x%x)", min_filter);
|
||||
throw EXCEPTION("Invalid max filter");
|
||||
}
|
||||
|
||||
D3D12_FILTER_TYPE get_mag_filter(u8 mag_filter)
|
||||
D3D12_FILTER_TYPE get_mag_filter(rsx::texture_magnify_filter mag_filter)
|
||||
{
|
||||
switch (mag_filter)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_NEAREST: return D3D12_FILTER_TYPE_POINT;
|
||||
case CELL_GCM_TEXTURE_LINEAR: return D3D12_FILTER_TYPE_LINEAR;
|
||||
case CELL_GCM_TEXTURE_CONVOLUTION_MAG: return D3D12_FILTER_TYPE_LINEAR;
|
||||
case rsx::texture_magnify_filter::nearest: return D3D12_FILTER_TYPE_POINT;
|
||||
case rsx::texture_magnify_filter::linear: return D3D12_FILTER_TYPE_LINEAR;
|
||||
case rsx::texture_magnify_filter::convolution_mag: return D3D12_FILTER_TYPE_LINEAR;
|
||||
}
|
||||
throw EXCEPTION("Invalid mag filter (0x%x)", mag_filter);
|
||||
throw EXCEPTION("Invalid mag filter");
|
||||
}
|
||||
}
|
||||
|
||||
D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter)
|
||||
D3D12_FILTER get_texture_filter(rsx::texture_minify_filter min_filter, rsx::texture_magnify_filter mag_filter)
|
||||
{
|
||||
D3D12_FILTER_TYPE min, mip;
|
||||
get_min_filter(min_filter, min, mip);
|
||||
|
|
|
@ -41,17 +41,17 @@ DXGI_FORMAT get_texture_format(u8 format);
|
|||
/**
|
||||
* Convert texture aniso value to UINT.
|
||||
*/
|
||||
UINT get_texture_max_aniso(u8 aniso);
|
||||
UINT get_texture_max_aniso(rsx::texture_max_anisotropy aniso);
|
||||
|
||||
/**
|
||||
* Convert texture wrap mode to D3D12_TEXTURE_ADDRESS_MODE
|
||||
*/
|
||||
D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(u8 wrap);
|
||||
D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(rsx::texture_wrap_mode wrap);
|
||||
|
||||
/**
|
||||
* Convert minify and magnify filter to D3D12_FILTER
|
||||
*/
|
||||
D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter);
|
||||
D3D12_FILTER get_texture_filter(rsx::texture_minify_filter min_filter, rsx::texture_magnify_filter mag_filter);
|
||||
|
||||
/**
|
||||
* Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY
|
||||
|
|
|
@ -47,17 +47,17 @@ namespace
|
|||
const u8 format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
|
||||
DXGI_FORMAT dxgi_format = get_texture_format(format);
|
||||
|
||||
if (texture.dimension() == 1) // 1D texture or cubemap
|
||||
if (texture.dimension() == rsx::texture_dimension::dimension1d)
|
||||
{
|
||||
return CD3DX12_RESOURCE_DESC::Tex1D(dxgi_format, texture.width(), 1, texture.get_exact_mipmap_count());
|
||||
}
|
||||
else if (texture.dimension() == 2) // 2D texture or cubemap
|
||||
else if (texture.dimension() == rsx::texture_dimension::dimension2d)
|
||||
{
|
||||
// if (texture.depth() < 2);
|
||||
size_t depth = (texture.cubemap()) ? 6 : 1;
|
||||
return CD3DX12_RESOURCE_DESC::Tex2D(dxgi_format, texture.width(), texture.height(), (UINT)depth, texture.get_exact_mipmap_count());
|
||||
}
|
||||
else if (texture.dimension() == 3) // 3d texture
|
||||
else if (texture.dimension() == rsx::texture_dimension::dimension3d)
|
||||
{
|
||||
return CD3DX12_RESOURCE_DESC::Tex3D(dxgi_format, texture.width(), texture.height(), texture.depth(), texture.get_exact_mipmap_count());
|
||||
}
|
||||
|
@ -146,13 +146,13 @@ ComPtr<ID3D12Resource> upload_single_texture(
|
|||
D3D12_SHADER_RESOURCE_VIEW_DESC get_srv_descriptor_with_dimensions(const rsx::texture &tex)
|
||||
{
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC shared_resource_view_desc = {};
|
||||
if (tex.dimension() == 1)
|
||||
if (tex.dimension() == rsx::texture_dimension::dimension1d)
|
||||
{
|
||||
shared_resource_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D;
|
||||
shared_resource_view_desc.Texture1D.MipLevels = tex.get_exact_mipmap_count();
|
||||
return shared_resource_view_desc;
|
||||
}
|
||||
if (tex.dimension() == 2)
|
||||
if (tex.dimension() == rsx::texture_dimension::dimension2d)
|
||||
{
|
||||
if (tex.cubemap())
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ D3D12_SHADER_RESOURCE_VIEW_DESC get_srv_descriptor_with_dimensions(const rsx::te
|
|||
shared_resource_view_desc.Texture2D.MipLevels = tex.get_exact_mipmap_count();
|
||||
return shared_resource_view_desc;
|
||||
}
|
||||
if (tex.dimension() == 3)
|
||||
if (tex.dimension() == rsx::texture_dimension::dimension3d)
|
||||
{
|
||||
shared_resource_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
|
||||
shared_resource_view_desc.Texture3D.MipLevels = tex.get_exact_mipmap_count();
|
||||
|
|
|
@ -830,6 +830,16 @@ rsx::fog_mode rsx::to_fog_mode(u32 in)
|
|||
throw EXCEPTION("Wrong fog mode %x", in);
|
||||
}
|
||||
|
||||
rsx::texture_dimension rsx::to_texture_dimension(u8 in)
|
||||
{
|
||||
switch (in)
|
||||
{
|
||||
case 1: return rsx::texture_dimension::dimension1d;
|
||||
case 2: return rsx::texture_dimension::dimension2d;
|
||||
case 3: return rsx::texture_dimension::dimension3d;
|
||||
}
|
||||
throw EXCEPTION("Wrong texture dimension %d", in);
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -867,8 +877,96 @@ enum
|
|||
CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8 = 15,
|
||||
CELL_GCM_SURFACE_A8B8G8R8 = 16,
|
||||
|
||||
// Wrap
|
||||
CELL_GCM_TEXTURE_WRAP = 1,
|
||||
CELL_GCM_TEXTURE_MIRROR = 2,
|
||||
CELL_GCM_TEXTURE_CLAMP_TO_EDGE = 3,
|
||||
CELL_GCM_TEXTURE_BORDER = 4,
|
||||
CELL_GCM_TEXTURE_CLAMP = 5,
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE = 6,
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER = 7,
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP = 8,
|
||||
|
||||
// Max Anisotropy
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_1 = 0,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_2 = 1,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_4 = 2,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_6 = 3,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_8 = 4,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_10 = 5,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_12 = 6,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_16 = 7,
|
||||
|
||||
// Texture Filter
|
||||
CELL_GCM_TEXTURE_NEAREST = 1,
|
||||
CELL_GCM_TEXTURE_LINEAR = 2,
|
||||
CELL_GCM_TEXTURE_NEAREST_NEAREST = 3,
|
||||
CELL_GCM_TEXTURE_LINEAR_NEAREST = 4,
|
||||
CELL_GCM_TEXTURE_NEAREST_LINEAR = 5,
|
||||
CELL_GCM_TEXTURE_LINEAR_LINEAR = 6,
|
||||
CELL_GCM_TEXTURE_CONVOLUTION_MIN = 7,
|
||||
CELL_GCM_TEXTURE_CONVOLUTION_MAG = 4,
|
||||
};
|
||||
|
||||
rsx::texture_wrap_mode rsx::to_texture_wrap_mode(u8 in)
|
||||
{
|
||||
switch (in)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_WRAP: return rsx::texture_wrap_mode::wrap;
|
||||
case CELL_GCM_TEXTURE_MIRROR: return rsx::texture_wrap_mode::mirror;
|
||||
case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return rsx::texture_wrap_mode::clamp_to_edge;
|
||||
case CELL_GCM_TEXTURE_BORDER: return rsx::texture_wrap_mode::border;
|
||||
case CELL_GCM_TEXTURE_CLAMP: return rsx::texture_wrap_mode::clamp;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return rsx::texture_wrap_mode::mirror_once_clamp_to_edge;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return rsx::texture_wrap_mode::mirror_once_border;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return rsx::texture_wrap_mode::mirror_once_clamp;
|
||||
}
|
||||
throw EXCEPTION("Unknow wrap mode %x", in);
|
||||
}
|
||||
|
||||
rsx::texture_max_anisotropy rsx::to_texture_max_anisotropy(u8 in)
|
||||
{
|
||||
switch (in)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_1: return rsx::texture_max_anisotropy::x1;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_2: return rsx::texture_max_anisotropy::x2;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_4: return rsx::texture_max_anisotropy::x4;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_6: return rsx::texture_max_anisotropy::x6;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_8: return rsx::texture_max_anisotropy::x8;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_10: return rsx::texture_max_anisotropy::x10;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_12: return rsx::texture_max_anisotropy::x12;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_16: return rsx::texture_max_anisotropy::x16;
|
||||
}
|
||||
throw EXCEPTION("Unknow anisotropy max mode %x", in);
|
||||
}
|
||||
|
||||
rsx::texture_minify_filter rsx::to_texture_minify_filter(u8 in)
|
||||
{
|
||||
switch (in)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_NEAREST: return rsx::texture_minify_filter::nearest;
|
||||
case CELL_GCM_TEXTURE_LINEAR: return rsx::texture_minify_filter::linear;
|
||||
case CELL_GCM_TEXTURE_NEAREST_NEAREST: return rsx::texture_minify_filter::nearest_nearest;
|
||||
case CELL_GCM_TEXTURE_LINEAR_NEAREST: return rsx::texture_minify_filter::linear_nearest;
|
||||
case CELL_GCM_TEXTURE_NEAREST_LINEAR: return rsx::texture_minify_filter::nearest_linear;
|
||||
case CELL_GCM_TEXTURE_LINEAR_LINEAR: return rsx::texture_minify_filter::linear_linear;
|
||||
case CELL_GCM_TEXTURE_CONVOLUTION_MIN: return rsx::texture_minify_filter::linear_linear;
|
||||
}
|
||||
throw EXCEPTION("Unknow minify filter %x", in);
|
||||
}
|
||||
|
||||
|
||||
rsx::texture_magnify_filter rsx::to_texture_magnify_filter(u8 in)
|
||||
{
|
||||
switch (in)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_NEAREST: return rsx::texture_magnify_filter::nearest;
|
||||
case CELL_GCM_TEXTURE_LINEAR: return rsx::texture_magnify_filter::linear;
|
||||
case CELL_GCM_TEXTURE_CONVOLUTION_MAG: return rsx::texture_magnify_filter::convolution_mag;
|
||||
}
|
||||
throw EXCEPTION("Unknow magnify filter %x", in);
|
||||
}
|
||||
|
||||
rsx::surface_target rsx::to_surface_target(u8 in)
|
||||
{
|
||||
switch (in)
|
||||
|
@ -1099,6 +1197,17 @@ namespace
|
|||
return "Error";
|
||||
}
|
||||
|
||||
std::string texture_dimension(u8 dim)
|
||||
{
|
||||
switch(rsx::to_texture_dimension(dim))
|
||||
{
|
||||
case rsx::texture_dimension::dimension1d: return "1D";
|
||||
case rsx::texture_dimension::dimension2d: return "2D";
|
||||
case rsx::texture_dimension::dimension3d: return "3D";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string surface_target(u32 target)
|
||||
{
|
||||
switch (rsx::to_surface_target(target))
|
||||
|
@ -1245,16 +1354,16 @@ namespace
|
|||
|
||||
std::string get_texture_wrap_mode(u8 wrap)
|
||||
{
|
||||
switch (wrap)
|
||||
switch (rsx::to_texture_wrap_mode(wrap))
|
||||
{
|
||||
case CELL_GCM_TEXTURE_WRAP: return "WRAP";
|
||||
case CELL_GCM_TEXTURE_MIRROR: return "MIRROR";
|
||||
case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return "CLAMP_TO_EDGE";
|
||||
case CELL_GCM_TEXTURE_BORDER: return "BORDER";
|
||||
case CELL_GCM_TEXTURE_CLAMP: return "CLAMP";
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return "MIRROR_ONCE_CLAMP_TO_EDGE";
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return "MIRROR_ONCE_BORDER";
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return "MIRROR_ONCE_CLAMP";
|
||||
case rsx::texture_wrap_mode::wrap: return "WRAP";
|
||||
case rsx::texture_wrap_mode::mirror: return "MIRROR";
|
||||
case rsx::texture_wrap_mode::clamp_to_edge: return "CLAMP_TO_EDGE";
|
||||
case rsx::texture_wrap_mode::border: return "BORDER";
|
||||
case rsx::texture_wrap_mode::clamp: return "CLAMP";
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp_to_edge: return "MIRROR_ONCE_CLAMP_TO_EDGE";
|
||||
case rsx::texture_wrap_mode::mirror_once_border: return "MIRROR_ONCE_BORDER";
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp: return "MIRROR_ONCE_CLAMP";
|
||||
}
|
||||
return "Error";
|
||||
}
|
||||
|
@ -1289,16 +1398,16 @@ namespace
|
|||
|
||||
std::string get_texture_max_aniso_name(u8 aniso)
|
||||
{
|
||||
switch (aniso)
|
||||
switch (rsx::to_texture_max_anisotropy(aniso))
|
||||
{
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_1: return "1";
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_2: return "2";
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_4: return "4";
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_6: return "6";
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_8: return "8";
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_10: return "10";
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_12: return "12";
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_16: return "16";
|
||||
case rsx::texture_max_anisotropy::x1 : return "1";
|
||||
case rsx::texture_max_anisotropy::x2: return "2";
|
||||
case rsx::texture_max_anisotropy::x4: return "4";
|
||||
case rsx::texture_max_anisotropy::x6: return "6";
|
||||
case rsx::texture_max_anisotropy::x8: return "8";
|
||||
case rsx::texture_max_anisotropy::x10: return "10";
|
||||
case rsx::texture_max_anisotropy::x12: return "12";
|
||||
case rsx::texture_max_anisotropy::x16: return "16";
|
||||
}
|
||||
return "Error";
|
||||
}
|
||||
|
|
|
@ -153,6 +153,65 @@ namespace rsx
|
|||
};
|
||||
|
||||
fog_mode to_fog_mode(u32 in);
|
||||
|
||||
enum class texture_dimension : u8
|
||||
{
|
||||
dimension1d,
|
||||
dimension2d,
|
||||
dimension3d,
|
||||
};
|
||||
|
||||
texture_dimension to_texture_dimension(u8 in);
|
||||
|
||||
enum class texture_wrap_mode : u8
|
||||
{
|
||||
wrap,
|
||||
mirror,
|
||||
clamp_to_edge,
|
||||
border,
|
||||
clamp,
|
||||
mirror_once_clamp_to_edge,
|
||||
mirror_once_border,
|
||||
mirror_once_clamp,
|
||||
};
|
||||
|
||||
texture_wrap_mode to_texture_wrap_mode(u8 in);
|
||||
|
||||
enum class texture_max_anisotropy : u8
|
||||
{
|
||||
x1,
|
||||
x2,
|
||||
x4,
|
||||
x6,
|
||||
x8,
|
||||
x10,
|
||||
x12,
|
||||
x16,
|
||||
};
|
||||
|
||||
texture_max_anisotropy to_texture_max_anisotropy(u8 in);
|
||||
|
||||
enum class texture_minify_filter : u8
|
||||
{
|
||||
nearest, ///< no filtering, mipmap base level
|
||||
linear, ///< linear filtering, mipmap base level
|
||||
nearest_nearest, ///< no filtering, closest mipmap level
|
||||
linear_nearest, ///< linear filtering, closest mipmap level
|
||||
nearest_linear, ///< no filtering, linear mix between closest mipmap levels
|
||||
linear_linear, ///< linear filtering, linear mix between closest mipmap levels
|
||||
convolution_min, ///< Unknow mode but looks close to linear_linear
|
||||
};
|
||||
|
||||
texture_minify_filter to_texture_minify_filter(u8 in);
|
||||
|
||||
enum class texture_magnify_filter : u8
|
||||
{
|
||||
nearest, ///< no filtering
|
||||
linear, ///< linear filtering
|
||||
convolution_mag, ///< Unknow mode but looks close to linear
|
||||
};
|
||||
|
||||
texture_magnify_filter to_texture_magnify_filter(u8 in);
|
||||
}
|
||||
|
||||
enum
|
||||
|
@ -229,26 +288,6 @@ enum
|
|||
// Normalization Flag
|
||||
CELL_GCM_TEXTURE_NR = 0x00,
|
||||
CELL_GCM_TEXTURE_UN = 0x40,
|
||||
|
||||
// Max Anisotropy
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_1 = 0,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_2 = 1,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_4 = 2,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_6 = 3,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_8 = 4,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_10 = 5,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_12 = 6,
|
||||
CELL_GCM_TEXTURE_MAX_ANISO_16 = 7,
|
||||
|
||||
// Wrap
|
||||
CELL_GCM_TEXTURE_WRAP = 1,
|
||||
CELL_GCM_TEXTURE_MIRROR = 2,
|
||||
CELL_GCM_TEXTURE_CLAMP_TO_EDGE = 3,
|
||||
CELL_GCM_TEXTURE_BORDER = 4,
|
||||
CELL_GCM_TEXTURE_CLAMP = 5,
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE = 6,
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER = 7,
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP = 8,
|
||||
};
|
||||
|
||||
// GCM Surface
|
||||
|
@ -360,16 +399,6 @@ enum
|
|||
CELL_GCM_TEXTURE_CYLINDRICAL_WRAP_ENABLE_TEX7_P = 1 << 30,
|
||||
CELL_GCM_TEXTURE_CYLINDRICAL_WRAP_ENABLE_TEX7_Q = 1 << 31,
|
||||
|
||||
// Texture Filter
|
||||
CELL_GCM_TEXTURE_NEAREST = 1,
|
||||
CELL_GCM_TEXTURE_LINEAR = 2,
|
||||
CELL_GCM_TEXTURE_NEAREST_NEAREST = 3,
|
||||
CELL_GCM_TEXTURE_LINEAR_NEAREST = 4,
|
||||
CELL_GCM_TEXTURE_NEAREST_LINEAR = 5,
|
||||
CELL_GCM_TEXTURE_LINEAR_LINEAR = 6,
|
||||
CELL_GCM_TEXTURE_CONVOLUTION_MIN = 7,
|
||||
CELL_GCM_TEXTURE_CONVOLUTION_MAG = 4,
|
||||
|
||||
CELL_GCM_COLOR_MASK_B = 1 << 0,
|
||||
CELL_GCM_COLOR_MASK_G = 1 << 8,
|
||||
CELL_GCM_COLOR_MASK_R = 1 << 16,
|
||||
|
|
|
@ -157,26 +157,31 @@ namespace rsx
|
|||
{
|
||||
namespace gl
|
||||
{
|
||||
static const int gl_tex_min_filter[] =
|
||||
int gl_tex_min_filter(rsx::texture_minify_filter min_filter)
|
||||
{
|
||||
GL_NEAREST, // unused
|
||||
GL_NEAREST,
|
||||
GL_LINEAR,
|
||||
GL_NEAREST_MIPMAP_NEAREST,
|
||||
GL_LINEAR_MIPMAP_NEAREST,
|
||||
GL_NEAREST_MIPMAP_LINEAR,
|
||||
GL_LINEAR_MIPMAP_LINEAR,
|
||||
GL_NEAREST, // CELL_GCM_TEXTURE_CONVOLUTION_MIN
|
||||
};
|
||||
switch (min_filter)
|
||||
{
|
||||
case rsx::texture_minify_filter::nearest: return GL_NEAREST;
|
||||
case rsx::texture_minify_filter::linear: return GL_LINEAR;
|
||||
case rsx::texture_minify_filter::nearest_nearest: return GL_NEAREST_MIPMAP_NEAREST;
|
||||
case rsx::texture_minify_filter::linear_nearest: return GL_LINEAR_MIPMAP_NEAREST;
|
||||
case rsx::texture_minify_filter::nearest_linear: return GL_NEAREST_MIPMAP_LINEAR;
|
||||
case rsx::texture_minify_filter::linear_linear: return GL_LINEAR_MIPMAP_LINEAR;
|
||||
case rsx::texture_minify_filter::convolution_min: return GL_LINEAR_MIPMAP_LINEAR;
|
||||
}
|
||||
throw EXCEPTION("Unknow min filter");
|
||||
}
|
||||
|
||||
static const int gl_tex_mag_filter[] =
|
||||
int gl_tex_mag_filter(rsx::texture_magnify_filter mag_filter)
|
||||
{
|
||||
GL_NEAREST, // unused
|
||||
GL_NEAREST,
|
||||
GL_LINEAR,
|
||||
GL_NEAREST, // unused
|
||||
GL_LINEAR // CELL_GCM_TEXTURE_CONVOLUTION_MAG
|
||||
};
|
||||
switch (mag_filter)
|
||||
{
|
||||
case rsx::texture_magnify_filter::nearest: return GL_NEAREST;
|
||||
case rsx::texture_magnify_filter::linear: return GL_LINEAR;
|
||||
case rsx::texture_magnify_filter::convolution_mag: return GL_LINEAR;
|
||||
}
|
||||
throw EXCEPTION("Unknow mag filter");
|
||||
}
|
||||
|
||||
static const int gl_tex_zfunc[] =
|
||||
{
|
||||
|
@ -200,36 +205,36 @@ namespace rsx
|
|||
glGenTextures(1, &m_id);
|
||||
}
|
||||
|
||||
int texture::gl_wrap(int wrap)
|
||||
int texture::gl_wrap(rsx::texture_wrap_mode wrap)
|
||||
{
|
||||
switch (wrap)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_WRAP: return GL_REPEAT;
|
||||
case CELL_GCM_TEXTURE_MIRROR: return GL_MIRRORED_REPEAT;
|
||||
case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return GL_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_BORDER: return GL_CLAMP_TO_BORDER;
|
||||
case CELL_GCM_TEXTURE_CLAMP: return GL_CLAMP;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return GL_MIRROR_CLAMP_TO_EDGE_EXT;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return GL_MIRROR_CLAMP_TO_BORDER_EXT;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return GL_MIRROR_CLAMP_EXT;
|
||||
case rsx::texture_wrap_mode::wrap: return GL_REPEAT;
|
||||
case rsx::texture_wrap_mode::mirror: return GL_MIRRORED_REPEAT;
|
||||
case rsx::texture_wrap_mode::clamp_to_edge: return GL_CLAMP_TO_EDGE;
|
||||
case rsx::texture_wrap_mode::border: return GL_CLAMP_TO_BORDER;
|
||||
case rsx::texture_wrap_mode::clamp: return GL_CLAMP;
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp_to_edge: return GL_MIRROR_CLAMP_TO_EDGE_EXT;
|
||||
case rsx::texture_wrap_mode::mirror_once_border: return GL_MIRROR_CLAMP_TO_BORDER_EXT;
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp: return GL_MIRROR_CLAMP_EXT;
|
||||
}
|
||||
|
||||
LOG_ERROR(RSX, "Texture wrap error: bad wrap (%d).", wrap);
|
||||
return GL_REPEAT;
|
||||
}
|
||||
|
||||
float texture::max_aniso(int aniso)
|
||||
float texture::max_aniso(rsx::texture_max_anisotropy aniso)
|
||||
{
|
||||
switch (aniso)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_1: return 1.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_2: return 2.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_4: return 4.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_6: return 6.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_8: return 8.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_10: return 10.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_12: return 12.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_16: return 16.0f;
|
||||
case rsx::texture_max_anisotropy::x1: return 1.0f;
|
||||
case rsx::texture_max_anisotropy::x2: return 2.0f;
|
||||
case rsx::texture_max_anisotropy::x4: return 4.0f;
|
||||
case rsx::texture_max_anisotropy::x6: return 6.0f;
|
||||
case rsx::texture_max_anisotropy::x8: return 8.0f;
|
||||
case rsx::texture_max_anisotropy::x10: return 10.0f;
|
||||
case rsx::texture_max_anisotropy::x12: return 12.0f;
|
||||
case rsx::texture_max_anisotropy::x16: return 16.0f;
|
||||
}
|
||||
|
||||
LOG_ERROR(RSX, "Texture anisotropy error: bad max aniso (%d).", aniso);
|
||||
|
@ -378,7 +383,7 @@ namespace rsx
|
|||
glTexParameteri(m_target, GL_TEXTURE_MIN_LOD, (tex.min_lod() >> 8));
|
||||
glTexParameteri(m_target, GL_TEXTURE_MAX_LOD, (tex.max_lod() >> 8));
|
||||
|
||||
int min_filter = gl_tex_min_filter[tex.min_filter()];
|
||||
int min_filter = gl_tex_min_filter(tex.min_filter());
|
||||
|
||||
if (min_filter != GL_LINEAR && min_filter != GL_NEAREST)
|
||||
{
|
||||
|
@ -390,7 +395,7 @@ namespace rsx
|
|||
}
|
||||
|
||||
glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, min_filter);
|
||||
glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, gl_tex_mag_filter[tex.mag_filter()]);
|
||||
glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, gl_tex_mag_filter(tex.mag_filter()));
|
||||
glTexParameterf(m_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_aniso(tex.max_aniso()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "OpenGL.h"
|
||||
#include "../GCM.h"
|
||||
|
||||
namespace rsx
|
||||
{
|
||||
|
@ -14,9 +15,9 @@ namespace rsx
|
|||
public:
|
||||
void create();
|
||||
|
||||
int gl_wrap(int wrap);
|
||||
int gl_wrap(rsx::texture_wrap_mode in);
|
||||
|
||||
float max_aniso(int aniso);
|
||||
float max_aniso(rsx::texture_max_anisotropy aniso);
|
||||
|
||||
inline static u8 convert_4_to_8(u8 v)
|
||||
{
|
||||
|
|
|
@ -205,7 +205,11 @@ static const std::string rsx_fp_op_names[] =
|
|||
"NULL", "BRK", "CAL", "IFE", "LOOP", "REP", "RET"
|
||||
};
|
||||
|
||||
enum class texture_dimension : u8
|
||||
|
||||
/**
|
||||
* Use an extra cubemap format
|
||||
*/
|
||||
enum class texture_dimension_extended : u8
|
||||
{
|
||||
texture_dimension_1d = 0,
|
||||
texture_dimension_2d = 1,
|
||||
|
@ -230,15 +234,15 @@ struct RSXFragmentProgram
|
|||
rsx::fog_mode fog_equation;
|
||||
u16 height;
|
||||
|
||||
texture_dimension get_texture_dimension(u8 id) const
|
||||
texture_dimension_extended get_texture_dimension(u8 id) const
|
||||
{
|
||||
return (texture_dimension)((texture_dimensions >> (id * 2)) & 0x3);
|
||||
return (texture_dimension_extended)((texture_dimensions >> (id * 2)) & 0x3);
|
||||
}
|
||||
|
||||
void set_texture_dimension(const std::array<texture_dimension, 16> &dimensions)
|
||||
void set_texture_dimension(const std::array<texture_dimension_extended, 16> &dimensions)
|
||||
{
|
||||
size_t id = 0;
|
||||
for (const texture_dimension &dim : dimensions)
|
||||
for (const texture_dimension_extended &dim : dimensions)
|
||||
{
|
||||
texture_dimensions &= ~(0x3 << (id * 2));
|
||||
u8 d = (u8)dim;
|
||||
|
|
|
@ -60,9 +60,9 @@ namespace rsx
|
|||
return ((method_registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 3) & 0x1);
|
||||
}
|
||||
|
||||
u8 texture::dimension() const
|
||||
rsx::texture_dimension texture::dimension() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 4) & 0xf);
|
||||
return rsx::to_texture_dimension((method_registers[NV4097_SET_TEXTURE_FORMAT + (m_index * 8)] >> 4) & 0xf);
|
||||
}
|
||||
|
||||
u8 texture::format() const
|
||||
|
@ -81,19 +81,19 @@ namespace rsx
|
|||
return std::min(mipmap(), max_mipmap_count);
|
||||
}
|
||||
|
||||
u8 texture::wrap_s() const
|
||||
rsx::texture_wrap_mode texture::wrap_s() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)]) & 0xf);
|
||||
return rsx::to_texture_wrap_mode((method_registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)]) & 0xf);
|
||||
}
|
||||
|
||||
u8 texture::wrap_t() const
|
||||
rsx::texture_wrap_mode texture::wrap_t() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 8) & 0xf);
|
||||
return rsx::to_texture_wrap_mode((method_registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 8) & 0xf);
|
||||
}
|
||||
|
||||
u8 texture::wrap_r() const
|
||||
rsx::texture_wrap_mode texture::wrap_r() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 16) & 0xf);
|
||||
return rsx::to_texture_wrap_mode((method_registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 16) & 0xf);
|
||||
}
|
||||
|
||||
u8 texture::unsigned_remap() const
|
||||
|
@ -136,9 +136,9 @@ namespace rsx
|
|||
return ((method_registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 7) & 0xfff);
|
||||
}
|
||||
|
||||
u8 texture::max_aniso() const
|
||||
rsx::texture_max_anisotropy texture::max_aniso() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 4) & 0x7);
|
||||
return rsx::to_texture_max_anisotropy((method_registers[NV4097_SET_TEXTURE_CONTROL0 + (m_index * 8)] >> 4) & 0x7);
|
||||
}
|
||||
|
||||
bool texture::alpha_kill_enabled() const
|
||||
|
@ -156,14 +156,14 @@ namespace rsx
|
|||
return float(f16((method_registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)]) & 0x1fff));
|
||||
}
|
||||
|
||||
u8 texture::min_filter() const
|
||||
rsx::texture_minify_filter texture::min_filter() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 16) & 0x7);
|
||||
return rsx::to_texture_minify_filter((method_registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 16) & 0x7);
|
||||
}
|
||||
|
||||
u8 texture::mag_filter() const
|
||||
rsx::texture_magnify_filter texture::mag_filter() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 24) & 0x7);
|
||||
return rsx::to_texture_magnify_filter((method_registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)] >> 24) & 0x7);
|
||||
}
|
||||
|
||||
u8 texture::convolution_filter() const
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "GCM.h"
|
||||
|
||||
namespace rsx
|
||||
{
|
||||
|
@ -18,7 +19,7 @@ namespace rsx
|
|||
u8 location() const;
|
||||
bool cubemap() const;
|
||||
u8 border_type() const;
|
||||
u8 dimension() const;
|
||||
rsx::texture_dimension dimension() const;
|
||||
u8 format() const;
|
||||
u16 mipmap() const;
|
||||
/**
|
||||
|
@ -28,9 +29,9 @@ namespace rsx
|
|||
u16 get_exact_mipmap_count() const;
|
||||
|
||||
// Address
|
||||
u8 wrap_s() const;
|
||||
u8 wrap_t() const;
|
||||
u8 wrap_r() const;
|
||||
rsx::texture_wrap_mode wrap_s() const;
|
||||
rsx::texture_wrap_mode wrap_t() const;
|
||||
rsx::texture_wrap_mode wrap_r() const;
|
||||
u8 unsigned_remap() const;
|
||||
u8 zfunc() const;
|
||||
u8 gamma() const;
|
||||
|
@ -41,7 +42,7 @@ namespace rsx
|
|||
bool enabled() const;
|
||||
u16 min_lod() const;
|
||||
u16 max_lod() const;
|
||||
u8 max_aniso() const;
|
||||
rsx::texture_max_anisotropy max_aniso() const;
|
||||
bool alpha_kill_enabled() const;
|
||||
|
||||
// Control1
|
||||
|
@ -49,8 +50,8 @@ namespace rsx
|
|||
|
||||
// Filter
|
||||
float bias() const;
|
||||
u8 min_filter() const;
|
||||
u8 mag_filter() const;
|
||||
rsx::texture_minify_filter min_filter() const;
|
||||
rsx::texture_magnify_filter mag_filter() const;
|
||||
u8 convolution_filter() const;
|
||||
bool a_signed() const;
|
||||
bool r_signed() const;
|
||||
|
|
|
@ -719,22 +719,22 @@ namespace rsx
|
|||
result.pixel_center_mode = rsx::to_window_pixel_center((shader_window >> 16) & 0xF);
|
||||
result.height = shader_window & 0xFFF;
|
||||
|
||||
std::array<texture_dimension, 16> texture_dimensions;
|
||||
std::array<texture_dimension_extended, 16> texture_dimensions;
|
||||
for (u32 i = 0; i < rsx::limits::textures_count; ++i)
|
||||
{
|
||||
if (!textures[i].enabled())
|
||||
texture_dimensions[i] = texture_dimension::texture_dimension_2d;
|
||||
else if (textures[i].dimension() == 1)
|
||||
texture_dimensions[i] = texture_dimension::texture_dimension_1d;
|
||||
else if (textures[i].dimension() == 2)
|
||||
texture_dimensions[i] = texture_dimension_extended::texture_dimension_2d;
|
||||
else if (textures[i].dimension() == rsx::texture_dimension::dimension1d)
|
||||
texture_dimensions[i] = texture_dimension_extended::texture_dimension_1d;
|
||||
else if (textures[i].dimension() == rsx::texture_dimension::dimension2d)
|
||||
{
|
||||
if (textures[i].cubemap())
|
||||
texture_dimensions[i] = texture_dimension::texture_dimension_cubemap;
|
||||
texture_dimensions[i] = texture_dimension_extended::texture_dimension_cubemap;
|
||||
else
|
||||
texture_dimensions[i] = texture_dimension::texture_dimension_2d;
|
||||
texture_dimensions[i] = texture_dimension_extended::texture_dimension_2d;
|
||||
}
|
||||
else if (textures[i].dimension() == 3)
|
||||
texture_dimensions[i] = texture_dimension::texture_dimension_3d;
|
||||
else if (textures[i].dimension() == rsx::texture_dimension::dimension3d)
|
||||
texture_dimensions[i] = texture_dimension_extended::texture_dimension_3d;
|
||||
else
|
||||
throw EXCEPTION("Unable to determine texture dimension");
|
||||
if (textures[i].enabled() && (textures[i].format() & CELL_GCM_TEXTURE_UN))
|
||||
|
|
|
@ -39,61 +39,60 @@ VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support,
|
|||
throw EXCEPTION("Invalid format (0x%x)", format);
|
||||
}
|
||||
|
||||
std::tuple<VkFilter, VkSamplerMipmapMode> get_min_filter_and_mip(u8 min_filter)
|
||||
std::tuple<VkFilter, VkSamplerMipmapMode> get_min_filter_and_mip(rsx::texture_minify_filter min_filter)
|
||||
{
|
||||
switch (min_filter)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_NEAREST: return std::make_tuple(VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case CELL_GCM_TEXTURE_LINEAR: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case CELL_GCM_TEXTURE_NEAREST_NEAREST: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case CELL_GCM_TEXTURE_LINEAR_NEAREST: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case CELL_GCM_TEXTURE_NEAREST_LINEAR: return std::make_tuple(VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_LINEAR);
|
||||
case CELL_GCM_TEXTURE_LINEAR_LINEAR: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_LINEAR);
|
||||
case CELL_GCM_TEXTURE_CONVOLUTION_MIN: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_LINEAR);
|
||||
case rsx::texture_minify_filter::nearest: return std::make_tuple(VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case rsx::texture_minify_filter::linear: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case rsx::texture_minify_filter::nearest_nearest: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case rsx::texture_minify_filter::linear_nearest: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST);
|
||||
case rsx::texture_minify_filter::nearest_linear: return std::make_tuple(VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_LINEAR);
|
||||
case rsx::texture_minify_filter::linear_linear: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_LINEAR);
|
||||
case rsx::texture_minify_filter::convolution_min: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_LINEAR);
|
||||
}
|
||||
throw EXCEPTION("Invalid max filter (0x%x)", min_filter);
|
||||
throw EXCEPTION("Invalid max filter");
|
||||
}
|
||||
|
||||
VkFilter get_mag_filter(u8 mag_filter)
|
||||
VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter)
|
||||
{
|
||||
switch (mag_filter)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_NEAREST: return VK_FILTER_NEAREST;
|
||||
case CELL_GCM_TEXTURE_LINEAR: return VK_FILTER_LINEAR;
|
||||
case CELL_GCM_TEXTURE_CONVOLUTION_MAG: return VK_FILTER_LINEAR;
|
||||
case rsx::texture_magnify_filter::nearest: return VK_FILTER_NEAREST;
|
||||
case rsx::texture_magnify_filter::linear: return VK_FILTER_LINEAR;
|
||||
case rsx::texture_magnify_filter::convolution_mag: return VK_FILTER_LINEAR;
|
||||
}
|
||||
throw EXCEPTION("Invalid mag filter (0x%x)", mag_filter);
|
||||
}
|
||||
|
||||
VkSamplerAddressMode vk_wrap_mode(u32 gcm_wrap)
|
||||
VkSamplerAddressMode vk_wrap_mode(rsx::texture_wrap_mode gcm_wrap)
|
||||
{
|
||||
switch (gcm_wrap)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_WRAP: return VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
case CELL_GCM_TEXTURE_MIRROR: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
||||
case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_BORDER: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||
case CELL_GCM_TEXTURE_CLAMP: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
default:
|
||||
throw EXCEPTION("unhandled texture clamp mode 0x%X", gcm_wrap);
|
||||
case rsx::texture_wrap_mode::wrap: return VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
case rsx::texture_wrap_mode::mirror: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
||||
case rsx::texture_wrap_mode::clamp_to_edge: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case rsx::texture_wrap_mode::border: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||
case rsx::texture_wrap_mode::clamp: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp_to_edge: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case rsx::texture_wrap_mode::mirror_once_border: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case rsx::texture_wrap_mode::mirror_once_clamp: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
}
|
||||
throw EXCEPTION("unhandled texture clamp mode");
|
||||
}
|
||||
|
||||
float max_aniso(u32 gcm_aniso)
|
||||
float max_aniso(rsx::texture_max_anisotropy gcm_aniso)
|
||||
{
|
||||
switch (gcm_aniso)
|
||||
{
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_1: return 1.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_2: return 2.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_4: return 4.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_6: return 6.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_8: return 8.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_10: return 10.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_12: return 12.0f;
|
||||
case CELL_GCM_TEXTURE_MAX_ANISO_16: return 16.0f;
|
||||
case rsx::texture_max_anisotropy::x1: return 1.0f;
|
||||
case rsx::texture_max_anisotropy::x2: return 2.0f;
|
||||
case rsx::texture_max_anisotropy::x4: return 4.0f;
|
||||
case rsx::texture_max_anisotropy::x6: return 6.0f;
|
||||
case rsx::texture_max_anisotropy::x8: return 8.0f;
|
||||
case rsx::texture_max_anisotropy::x10: return 10.0f;
|
||||
case rsx::texture_max_anisotropy::x12: return 12.0f;
|
||||
case rsx::texture_max_anisotropy::x16: return 16.0f;
|
||||
}
|
||||
|
||||
throw EXCEPTION("Texture anisotropy error: bad max aniso (%d).", gcm_aniso);
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace vk
|
|||
gpu_formats_support get_optimal_tiling_supported_formats(VkPhysicalDevice physical_device);
|
||||
VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format format);
|
||||
|
||||
std::tuple<VkFilter, VkSamplerMipmapMode> get_min_filter_and_mip(u8 min_filter);
|
||||
VkFilter get_mag_filter(u8 mag_filter);
|
||||
VkSamplerAddressMode vk_wrap_mode(u32 gcm_wrap);
|
||||
float max_aniso(u32 gcm_aniso);
|
||||
std::tuple<VkFilter, VkSamplerMipmapMode> get_min_filter_and_mip(rsx::texture_minify_filter min_filter);
|
||||
VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter);
|
||||
VkSamplerAddressMode vk_wrap_mode(rsx::texture_wrap_mode gcm_wrap);
|
||||
float max_aniso(rsx::texture_max_anisotropy gcm_aniso);
|
||||
VkComponentMapping get_component_mapping(u32 format, u8 swizzle_mask);
|
||||
VkPrimitiveTopology get_appropriate_topology(rsx::primitive_type& mode, bool &requires_modification);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue